home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr53 / 117_01.zip / COOKBOOK < prev    next >
Text File  |  1993-06-22  |  107KB  |  4,200 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6. #-h-     toc.c                         1393    local     01/07/81
  7. 15:36:45
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81.  
  82.  
  83.                          C O O K B O O K
  84.  
  85.  
  86.     Instructions for Implementing the Software Tools Package
  87.        (As distributed by the Software Tools Users Group)
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98.                           Prepared by:
  99.  
  100.                Debbie Scherrer
  101.                Advanced Systems Research Group
  102.                Computer Science and Mathematics Department
  103.                Lawrence Berkeley Laboratory
  104.                Berkeley, CA  94720
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.                           January 1981
  117.  
  118.  
  119.  
  120.  
  121.                             LBID 098
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130. COOKBOOK                                        Table of Contents
  131.  
  132.  
  133.                         TABLE OF CONTENTS
  134.  
  135.  
  136.  
  137.                              Part 1
  138.  
  139.  
  140. Summary of Tools and Library Routines
  141.  
  142. Introduction
  143.  
  144. File 2 - Copy (in Fortran)
  145.  
  146. File 3 - Ratfor bootstrap (in Fortran)
  147.  
  148. File 4 - Library Routines, Symbol Definitions, and
  149.         Temporary Versions of the Primitives
  150.  
  151. File 5 - Reading Command Line Arguments - Echo and Getarg
  152.  
  153. File 6 - The CAT tool for testing File Access Primitives
  154.  
  155. File 7 - File Insertion - Incl
  156.  
  157. File 8 - Ratfor in ratfor
  158.  
  159. ------ - In-Core Editing.
  160.  
  161. File 9 - Text Formatting
  162.  
  163. File 10 - File Archiving
  164.  
  165. File 11 - Text Editing - Random IO Primitives
  166.  
  167. File 12 - The Remainder of the Basic Tools
  168.  
  169. File 13 - The Shell
  170.  
  171. File 14 - Documentation
  172.  
  173. File 15 - Additional Tools (which have been included as
  174.          they were received; some may require additional
  175.          primitives)
  176.  
  177. File 16 - Spelling Dictionary
  178.  
  179.  
  180.  
  181.                              Part 2
  182.  
  183. Specifications    for    System-dependent     Primitives     #-t-
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191. COOKBOOK                                        Table of Contents
  192.  
  193.  
  194. toc.c                        1393    local    01/07/81   15:36:45
  195. #-h-    summary.c                    9301     local      01/09/81
  196. 14:18:05
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204.  
  205.  
  206.  
  207.  
  208.  
  209.  
  210.  
  211.  
  212.  
  213.  
  214.  
  215.  
  216.  
  217.  
  218.  
  219.  
  220.  
  221.  
  222.  
  223.  
  224.  
  225.  
  226.  
  227.  
  228.  
  229.  
  230.  
  231.  
  232.  
  233.  
  234.  
  235.  
  236.  
  237.  
  238.  
  239.  
  240.  
  241.  
  242.  
  243.  
  244.  
  245.  
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.                    SUMMARY OF CONTENTS OF TAPE
  256.  
  257.  
  258. 1.  TOOLS
  259.  
  260.       ar ................................. archive file maintainer
  261.       cat ....................... concatenate and print text files
  262.       ch .................................... change text patterns
  263.       comm ....................... print lines common to two files
  264.       cpress ................................ compress input files
  265.       crt ..................................copy files to terminal
  266.       crypt ................... encrypt and decrypt standard input
  267.       date ............................... print the date and time
  268.       dc ......................................... desk calculator
  269.       detab ............................... convert tabs to spaces
  270.       diff ..................... isolate differences between files
  271.       echo ........................... echo command line arguments
  272.       ed .................................................. editor
  273.       edin ........................................ in-core editor
  274.       entab .................... convert spaces to tabs and spaces
  275.       expand .............................. uncompress input files
  276.       fb ................ search blocks of lines for text patterns
  277.       field ............................ manipulate fields of data
  278.       find ....................... search a file for text patterns
  279.       format ......................................... format text
  280.       includ ......................... file inclusion preprocessor
  281.       kwic ............ prepare lines for keyword-in-context index
  282.       lam ......................................... laminate files
  283.       ll ...................................... print line lengths
  284.       macro ...................... general-purpose macro processor
  285.       mcol ................................ multicolumn formatting
  286.       mv .................................... move (rename) a file
  287.       os .................. convert backspaces into multiple lines
  288.       pl ................... print specified lines/pages in a file
  289.       pr .............................................. print file
  290.       ratfor ................................. Ratfor preprocessor
  291.       rev .......................................... reverse lines
  292.       rm ................................... remove (delete) files
  293.       roff ........................................ [see 'format']
  294.       sedit ........................................ stream editor
  295.       sh ................................ command line interpreter
  296.       show ......................... show all characters in a file
  297.       sort .......................... sort and/or merge text files
  298.       spell ............................... locate spelling errors
  299.       split ............................... split file into pieces
  300.       tail ............................ print last lines of a file
  301.       tee ................... copy input to output and named files
  302.       tr ............................... character transliteration
  303.       tsort ........................... topologically sort symbols
  304.       uniq ............. strip adjacent repeated lines from a file
  305.       unrot ...................... unrotate lines prepared by kwic
  306.  
  307.  
  308.                                -1-
  309.  
  310.  
  311.  
  312.  
  313.  
  314.  
  315.  
  316.       wc ............. count lines, words, and characters in files
  317.       xref ..................... make a cross reference of symbols
  318.  
  319.  
  320. 2.  SUBROUTINES AND PRIMITIVES
  321.  
  322.       (*  indicates  that  the  implementation  of the routine is
  323.       system-dependent
  324.       # indicates  that  the  routine  may,  in  some  cases,  be
  325.       system-dependent)
  326.  
  327.  
  328.     definitions .................... standard Ratfor definitions
  329.  
  330.     File Manipulation
  331.      #amove ......................... move (rename) file1 to file2
  332.      *close ................................ close (detach) a file
  333.      *create .... create a new file (or overwrite an existing one)
  334.      *gettyp .............. get type of file (character or binary)
  335.      *isatty .......... determine if file is a teletype/CRT device
  336.      #mkuniq ........................... generate unique file name
  337.      *open ... open an existing file for reading, writing, or both
  338.      *remove .................. remove a file from the file system
  339.  
  340.     I/O
  341.       fcopy ............................. copy file in to file out
  342.      *flush .................... flush output buffer for file 'fd'
  343.       getc .................... read character from standard input
  344.      *getch ............................. read character from file
  345.      #getlin ............................. get next line from file
  346.      *note ....................... determine current file position
  347.      #prompt ............................... prompt user for input
  348.       putc .................... write character to standard output
  349.      *putch .............................. write character to file
  350.       putdec .................. write integer n in field width >=w
  351.       putint ..... write integer n onto file fd in field width >=w
  352.      #putlin ..................... output a line onto a given file
  353.       putstr ........... write str onto file fd in field width >=w
  354.      *readf ............................. read from an opened file
  355.      *remark ........................... print single-line message
  356.      *seek ............................... move read/write pointer
  357.      *writef ............................. write to an opened file
  358.  
  359.     Process Control
  360.      *spawn ...................................... execute subtask
  361.  
  362.     String Manipulation
  363.       addset ........... put c in array(j) if it fits, increment j
  364.       addstr ...... add string s to str(j) if it fits, increment j
  365.       clower ................................ fold c to lower case
  366.       concat ...................... concatenate 2 strings together
  367.  
  368.  
  369.                                -2-
  370.  
  371.  
  372.  
  373.  
  374.  
  375.  
  376.  
  377.       ctoc ................................. copy string-to-string
  378.       ctoi ....... convert string at in(i) to integer, increment i
  379.       ctomn  ....... translate ascii control character toámnemonic
  380.       cupper ..................... convert character to upper case
  381.       equal ............ compare str1 to str2; return YES if equal
  382.       esc .... map array(i) into escaped character, if appropriate
  383.       fold .......................... convert string to lower case
  384.       gctoi .......... generalized character-to-integer conversion
  385.       getwrd . get non-blank word from in(i) into out, increment i
  386.       gitoc .......... generalized integer-to-character conversion
  387.       index ....................... find character c in string str
  388.       itoc ................... convert integer to character string
  389.       length ............................ compute length of string
  390.       lower ......................... convert string to lower case
  391.       mntoc ......................... ascii mneumonic to character
  392.       scopy ...................... copy string at from(i) to to(j)
  393.       sdrop ........................ drop characters from a string
  394.       skipbl ...................... skip blanks and tabs at str(i)
  395.       stake ........................ take characters from a string
  396.       stcopy ........ copy string at from(i) to to(j); increment j
  397.       strcmp ................................... compare 2 strings
  398.       strim .......... trim trailing blanks and tabs from a string
  399.       substr ...................... take a substring from a string
  400.       type ........................... determine type of character
  401.       upper ......................... convert string to upper case
  402.  
  403.     Pattern Matching
  404.       amatch ........ look for pattern matching regular expression
  405.       getpat .......encode regular expression for pattern matching
  406.       makpat ...... encode regular expression for pattern matching
  407.       match ....................... match pattern anywhere on line
  408.  
  409.     Command Line Handling
  410.      *delarg ............. delete command line argument number 'n'
  411.      *getarg .......................... get command line arguments
  412.       gfnarg .......................... get next filename argument
  413.       query ...................... print command usage information
  414.  
  415.     Dynamic Storage Allocation
  416.       dsfree ..................... free a block of dynamic storage
  417.       dsget .................... obtain a block of dynamic storage
  418.       dsinit .......................... initialize dynamic storage
  419.  
  420.     Symbol Table Manipulation
  421.       delete ................... remove a symbol from symbol table
  422.       enter ......................... place symbol in symbol table
  423.       lookup ..... get string associated with name from hash table
  424.       mktabl ................................. make a symbol table
  425.       rmtabl ............................... remove a symbol table
  426.       sctabl .................. scan all symbols in a symbol table
  427.  
  428.  
  429.  
  430.                                -3-
  431.  
  432.  
  433.  
  434.  
  435.  
  436.  
  437.  
  438.     Date Manipulation
  439.       fmtdat .................... convert date to character string
  440.      *getnow ........................... get current date and time
  441.       wkday ...... get day-of-week corresponding to month-day-year
  442.  
  443.     Error Handling
  444.       cant ...... print 'name: can't open' and terminate execution
  445.       error .... print single-line message and terminate execution
  446.  
  447.     Miscellaneous
  448.      *endst . close all open files and terminate program execution
  449.      *initst .. initialize all standard files and common variables
  450.  
  451.  
  452. 3.  ADDITIONAL TOOLS AND LIBRARY ROUTINES
  453.  
  454.       As assortment of tools and library routines including:
  455.  
  456.           1)   Alternate  versions  of  tools included earlier on
  457.           the tape
  458.           2)  Tools requiring additional primitives
  459.           3)  Experimental tools and routines
  460.           4)  Other tools and routines not yet accepted  as  part
  461.           of the basic package
  462.  
  463.  
  464. 4.  COMPLETE DOCUMENTATION FOR TOOLS AND LIBRARY ROUTINES
  465.  
  466.  
  467. 5.  PRIMERS
  468.  
  469.       edit ................................................ editor
  470.       ratfor ................................. ratfor preprocessor
  471.  
  472.  
  473. 6.  SPELLING DICTIONARY
  474. #-t-     summary.c                     9301    local     01/09/81
  475. 14:18:05    #-h-     intro.c                       5631     local
  476. 01/07/81  15:36:49
  477.  
  478.  
  479.  
  480.  
  481.  
  482.  
  483.  
  484.  
  485.  
  486.  
  487.  
  488.  
  489.  
  490.  
  491.                                -4-
  492.  
  493.  
  494.  
  495.  
  496. COOKBOOK                                             Introduction
  497.  
  498.  
  499.             GUIDELINES FOR INSTALLING SOFTWARE TOOLS
  500.  
  501.                           Introduction
  502.  
  503. The  purpose  of  this document is to provide a checkout scenario
  504. for  installing  an  enhanced  version  of   the   Addison-Wesley
  505. Software  Tools  package  developed  by B. W. Kernighan and P. J.
  506. Plauger  in  conjunction  with  their  book   "Software   Tools".
  507. Accompanying  this  document  is  a  tape providing ratfor source
  508. code and documentation for  enhanced  versions  of  the  original
  509. tools,   as  well  as  additional  useful  tools  and a UNIX-like
  510. shell.  (Unix is a registered trademark  of  Bell  Labs...)  This
  511. manual  assumes you have read and understand the 'Software Tools'
  512. book and are at least vaguely familiar with  the  UNIX  operating
  513. system concepts.
  514.  
  515. One  of  the  purposes  of  the "Software Tools" experiment is to
  516. provide  users  of  a  multitude  of  operating  systems  with  a
  517. portable  set  of  common program development tools.  These tools
  518. are made 'portable' via two mechanisms:
  519.  
  520.      1.  All source is written in ratfor, a fortran  preprocessor
  521.      language which is directly translatable into fortran.
  522.      2.   Most  system-dependent  quantities are pushed down into
  523.      "primitive" function calls, which are left up to the  person
  524.      in charge of bringing up the tools to implement.
  525.  
  526. This  documentation  is designed to assist the implementor of the
  527. ratfor preprocessor and primitives to bring up her  version  with
  528. as much ease as possible.
  529.  
  530. The   first   section   of   the   manual  contains  step-by-step
  531. instructions for dealing with each of  the  files  on  the  tape.
  532. The  files  have  been  arranged  to  allow  you  to develop your
  533. primitives in a reasonable order, while bringing up  some  useful
  534. tools  at the same time.  Along with a description of each of the
  535. files is a list of the  primitives  you'll  need  to  develop  to
  536. implement   the   file,  a  list  of  primitives  you've  already
  537. developed  which  the  tool  will  need,  and   suggestions   for
  538. implementation of the tool.
  539.  
  540. The  second  section of this manual gives detailed specifications
  541. for the design of your  system-dependent  primitives.   Following
  542. these  specifications  as closely as possible when you write your
  543. primitives  will  help  you  bring  up  the  tools   with   fewer
  544. problems.
  545.  
  546.  
  547.                       Implementation Issues
  548.  
  549. The   most   difficult   problems   facing   the  software  tools
  550.  
  551.  
  552.                                -5-
  553.  
  554.  
  555.  
  556.  
  557. COOKBOOK                                             Introduction
  558.  
  559.  
  560. implementor  are:  character  sets,  passing   command   argument
  561. strings  to  a  running  program, random access to files, and (if
  562. the shell is desired) execution of subtasks.
  563.  
  564. Character sets:  The main purpose of the tools is  to  provide  a
  565. rational  environment  in  which  to  do program development.  We
  566. feel that accomplishing this requires a 128 character  set  as  a
  567. minimum.   However,  the tools may be installed with a restricted
  568. character set if there is no alternative.  If this is  the  case,
  569. we  urge  the implementor to at least develop some sort of escape
  570. conventions.
  571.  
  572. Passing command line arguments:  Every  system  has  a  different
  573. (and  invariably  inadequate)  way  of accomplishing this.  Often
  574. arguments are 'gratuitously'  folded  to  a  single  case.   Some
  575. systems  even  forbid  "uninstalled"  programs from reading their
  576. own arguments.  Since the ability to read command line  arguments
  577. is  vital  to  tool  utility,  this problem will have to be faced
  578. early.   In  the  absolute  worst  case,  the  arguments  can  be
  579. prompted for by the running program.
  580.  
  581. Random  Access  to  Files:  This capability is necessary only for
  582. running the  editor.   If  random  access  is  not  possible,  an
  583. in-core version of the editor is provided.
  584.  
  585. Execution   of  subtasks:   The  command  line  interpreter  (the
  586. 'shell') will need to be able to spawn  subtasks.   Almost  every
  587. system  has  the  ability  to roll executing programs in and out;
  588. however, many of them do not give the user easy  access  to  this
  589. capability.   To  run  the shell the implementor must devise some
  590. (perhaps devious) method of causing the execution  of  a  desired
  591. task.
  592.  
  593.  
  594.                        Format of the tape
  595.  
  596. There  are  16 files on the tape.  File 1 contains this document,
  597. which describes the remainder of the files.
  598.  
  599. If you look at the tape files you'll  notice  that  most  of  the
  600. source  code  contains  archive  headers  and  trailers (that is,
  601. lines that  begin  with  "#-h-"  and  "#-t-"  respectively).   We
  602. maintain  all  our sources with the archiver, making each routine
  603. a member of the source file. This file is in turn  combined  with
  604. the  documentation  and  common  block  files  to  make one large
  605. working archive for each tool.  Thus, each tool on  the  tape  is
  606. an  archived  file  containing  the documentation, common blocks,
  607. and source code.  These archives generally have the format:
  608.  
  609.          main archive
  610.                tool.doc       (documentation)
  611.  
  612.  
  613.                                -6-
  614.  
  615.  
  616.  
  617.  
  618. COOKBOOK                                             Introduction
  619.  
  620.  
  621.                cblock1        (common blocks)
  622.                cblock2
  623.                ...
  624.                tool.r         (source code)
  625.                   rtn1        (each routine is a
  626.                   rtn2           sub-achive member)
  627.                   ...
  628. Each  archive  header  contains  the  file  name,  its  size   in
  629. characters,  and  the  last date and time the member was changed.
  630. When you bring up the archiver on File 10, you  can  continue  to
  631. maintain your source in this format.
  632.  
  633.  
  634. ACKNOWLEDGEMENTS
  635.  
  636. The  tools  distributed  on  this tape represent a compilation of
  637. some of the most useful tools available from  the  University  of
  638. Arizona,  Georgia  Institute of Technology, and Lawrence Berkeley
  639. Laboratory.  I would like to especially  thank  Allen  Akin  (GT)
  640. and  David  Hanson  (U.  of  Arizona) for their help in preparing
  641. these tools for distribution.
  642.  
  643.  
  644.  
  645.  
  646.  
  647. Depending upon the services your system provides, you can  expect
  648. to  spend anywhere from one week to several months developing the
  649. primitives    for    your     tools.      Good     luck!     #-t-
  650. intro.c                      5631    local    01/07/81   15:36:49
  651. #-h-    file2.c                      2349     local      01/07/81
  652. 15:36:51
  653.  
  654.  
  655.  
  656.  
  657.  
  658.  
  659.  
  660.  
  661.  
  662.  
  663.  
  664.  
  665.  
  666.  
  667.  
  668.  
  669.  
  670.  
  671.  
  672.  
  673.  
  674.                                -7-
  675.  
  676.  
  677.  
  678.  
  679. FILE 2                       7/31/80                       FILE 2
  680.  
  681.  
  682.                         COPY (in Fortran)
  683.  
  684.  
  685. DESCRIPTION
  686.      'Copy'  represents the IO routines extracted from the ratfor
  687.      bootstrap for easier testing.  Copy  reads  an  input  file,
  688.      converts  the  input  characters  to  ascii  strings via the
  689.      routine 'inmap', converts them  back  to  local  format  via
  690.      'outmap',  and  copies them to an output file.  (Don't worry
  691.      about the somewhat abstruse Fortran in which  this  tool  is
  692.      written;  this  is  the  output from the ratfor preprocessor
  693.      and one  generally never has to look at it.)
  694.  
  695.      Copy also makes a simple call to "remark", a  routine  which
  696.      receives  a  hollerith  character string and sends it to the
  697.      user's terminal.
  698.  
  699. CHANGES YOU MIGHT HAVE TO MAKE
  700.      The input file is defined as unit 5 and output  as  unit  6;
  701.      change  these  in  the READ and WRITE statements if they are
  702.      different for your system.   The  end-of-file  test  is  one
  703.      commonly used, but not supported on all systems.
  704.  
  705.      On  some  systems,  the routine 'putch' needs an extra blank
  706.      character at the beginning of  each  line  when  writing  to
  707.      certain  devices  such  as  terminals  or printers.  If your
  708.      system has this 'feature', modify the write statement.
  709.  
  710.  
  711.      Look at the routine "remark".  You'll most  likely  have  to
  712.      change  the WRITE statement to print hollerith characters in
  713.      whatever manner your  system  demands.   Don't  worry  about
  714.      finding  the  end of the hollerith array; simply print 20 or
  715.      so characters.  Later on, you will rewrite remark to  handle
  716.      strings gracefully.
  717.  
  718.      You  should  attempt  to  run  the alphabet (upper and lower
  719.      cases if your system allows both), the digits, and all  your
  720.      special  characters through copy to make sure they emerge as
  721.      they should.  If they don't,  inspect  the  'inmap'-'outmap'
  722.      routines,  which  convert  from  a  fortran  character in 1H
  723.      format  to  an   integer   representation   of   the   ascii
  724.      characters.
  725.  
  726.      After  you  can  properly  read  from and write to the users
  727.      terminal, attempt to associate logical units 5  and  6  with
  728.      physical  file  names.   If  your  command language supports
  729.      this, use it  for  now.   Otherwise,  rummage  through  your
  730.      Fortran  manual  for  terms  like ASSIGN or OPEN, and modify
  731.      copy accordingly for testing with disk files.
  732.  
  733.  
  734.  
  735.                                -8-
  736.  
  737.  
  738.  
  739.  
  740. FILE 2                       7/31/80                       FILE 2
  741.  
  742.  
  743. NEW PRIMITIVES TO WRITE
  744.      (inmap/outmap)
  745.  
  746. OTHER PRIMITIVES USED
  747.      None
  748.  
  749. ROUTINES NEEDED FROM OTHER TOOLS
  750.      None   #-t-     file2.c                       2349     local
  751.      01/07/81   15:36:51  #-h-   file3.c                     1093
  752.      local   01/07/81  15:36:53
  753.  
  754.  
  755.  
  756.  
  757.  
  758.  
  759.  
  760.  
  761.  
  762.  
  763.  
  764.  
  765.  
  766.  
  767.  
  768.  
  769.  
  770.  
  771.  
  772.  
  773.  
  774.  
  775.  
  776.  
  777.  
  778.  
  779.  
  780.  
  781.  
  782.  
  783.  
  784.  
  785.  
  786.  
  787.  
  788.  
  789.  
  790.  
  791.  
  792.  
  793.  
  794.  
  795.  
  796.                                -9-
  797.  
  798.  
  799.  
  800.  
  801. FILE 3                       7/31/80                       FILE 3
  802.  
  803.  
  804.                         RATFOR BOOTSTRAP
  805.  
  806.  
  807. DESCRIPTION
  808.      The ratfor bootstrap, in fortran.   The  bootstrap  contains
  809.      most  of  the  ratfor capabilities except for the 'include'.
  810.      You'll use this bootstrap version for creating  some  simple
  811.      tools  and  for  developing  your  system  primitives.   The
  812.      complete ratfor compiler will  come  later,  after  you  can
  813.      directly access files and perform more powerful IO.
  814.  
  815.      Don't   be   overly  concerned  with  the  slowness  of  the
  816.      bootstrap, which uses Fortran IO.  When  you  implement  the
  817.      full   ratfor,   you  will  use  your  own,  more  efficient
  818.      primitives which will speed up the processing.
  819.  
  820. CHANGES YOU MIGHT HAVE TO MAKE
  821.      Whatever changes you might have to make  are  determined  by
  822.      what your fortran compiler will or will not accept...
  823.  
  824. NEW PRIMITIVES TO WRITE
  825.      None
  826.  
  827. OTHER PRIMITIVES USED
  828.      There are dummy primitives provided in the bootstrap.
  829.  
  830. ROUTINES NEEDED FROM OTHER TOOLS
  831.      Combine  the bootstrap with getch, putch, remark, inmap, and
  832.      outmap from File 1.
  833.      #-t-   file3.c                     1093   local     01/07/81
  834.      15:36:53   #-h-    file4.c                      1189   local
  835.      01/07/81  15:36:54
  836.  
  837.  
  838.  
  839.  
  840.  
  841.  
  842.  
  843.  
  844.  
  845.  
  846.  
  847.  
  848.  
  849.  
  850.  
  851.  
  852.  
  853.  
  854.  
  855.  
  856.  
  857.                               -10-
  858.  
  859.  
  860.  
  861.  
  862. FILE 4                       7/31/79                       FILE 4
  863.  
  864.  
  865.             SYMBOL DEFINITIONS, LIBRARY ROUTINES, AND
  866.                       TEMPORARY PRIMITIVES
  867.  
  868.  
  869. DESCRIPTION
  870.      The fourth file contains  the  general  symbol  definitions,
  871.      some  generally  useful  library  routines,  and  a  set  of
  872.      temporary  primitives  which  you  can  use  to  assist   in
  873.      developing  your  own  primitives.  They will be useful as a
  874.      test program for the bootstrap and  as  a  teaching  aid  to
  875.      help you learn the ratfor language.
  876.  
  877. CHANGES YOU MIGHT HAVE TO MAKE
  878.      Take  a  look  at  the  symbol  definitions.  Comments in it
  879.      point you to symbols that might  have  to  change  for  your
  880.      system (e.g. FILENAMESIZE).
  881.  
  882.      It  is  the  "real" versions of the primitives that you will
  883.      have to implement on your system.  The rest of  this  manual
  884.      is  designed  to  simplify  that  procedure.  However, right
  885.      now, just try to get File 4 to  run  through  the  bootstrap
  886.      and your fortran compiler.
  887.  
  888. NEW PRIMITIVES TO WRITE
  889.      You'll  have  to change the version of "remark" on this file
  890.      to whatever you made it do on File 1.
  891.  
  892. OTHER PRIMITIVES USED
  893.      None
  894.  
  895. ROUTINES NEEDED FROM OTHER TOOLS
  896.      Use the 'inmap'/'outmap' pair from COPY.
  897.      #-t-   file4.c                     1189   local     01/07/81
  898.      15:36:54   #-h-    file5.c                      3225   local
  899.      01/07/81  15:36:55
  900.  
  901.  
  902.  
  903.  
  904.  
  905.  
  906.  
  907.  
  908.  
  909.  
  910.  
  911.  
  912.  
  913.  
  914.  
  915.  
  916.  
  917.  
  918.                               -11-
  919.  
  920.  
  921.  
  922.  
  923. FILE 5                       7/31/79                       FILE 5
  924.  
  925.  
  926.                     READING COMMAND ARGUMENTS
  927.                          ECHO and GETARG
  928.  
  929.  
  930. DESCRIPTION
  931.      Now the real work begins.   The  tool  'echo'  does  nothing
  932.      more  than  read the command line arguments passed to it and
  933.      print  them  on  the   standard   output   (hopefully   your
  934.      terminal).    However,  for  this  tool  you  will  have  to
  935.      implement 'getarg'.   Find  the  design  specifications  for
  936.      'getarg'  and  'delarg' in Section 2 of this manual and read
  937.      them carefully.
  938.  
  939. CHANGES YOU MIGHT HAVE TO MAKE
  940.      The documentation for echo (and all the tools) precedes  the
  941.      source  code.   Remove it and store it someplace convenient.
  942.      (All the documentation is also provided as a  user's  manual
  943.      on File 14.)
  944.  
  945.      Before  compiling  echo,  you'll  have  to  copy the general
  946.      symbol definitions onto the front of the file.
  947.  
  948.      The temporary primitives provide a version of  getarg  which
  949.      prompts  the  user  for the command line arguments.  If this
  950.      is the ONLY way you can implement getarg, then it will  have
  951.      to  do.   First  test  "echo" with these temporary versions,
  952.      before attempting to create your own.
  953.  
  954.      As you create your primitives, initialization routines  will
  955.      probably  be  necessary.   We  have called ours 'initst' and
  956.      'endst',  and  we  have  included  them  in  the   temporary
  957.      primitives  on  File  4.   We  have  also written the DRIVER
  958.      macro to automaically call them for us.  (If  you  can  have
  959.      your  system  automatically  do  the initialization, so much
  960.      the  better.)  As  you  develop  your  'getarg'  and   other
  961.      primitives,    insert    into   the   initst   routine   any
  962.      initialization which must be done to allow them to run.
  963.  
  964.      Then, when writing your own getarg, look  at  the  temporary
  965.      primitives,  especially 'makarg' and 'initst'.  Makarg picks
  966.      up the arguments and puts them in an  array  which  'getarg'
  967.      subsequently  reads.   All you need do is change 'makarg' to
  968.      pick up the command line from your  system,  convert  it  to
  969.      ascii  if  necessary,  and  store it in the array.  Then the
  970.      rest of the code can remain unchanged.
  971.  
  972.      Also, while looking at initst, notice that it  calls  getarg
  973.      to  look  for  file substitutions for the STDIN, STDOUT, and
  974.      ERROUT files, which are generally the user's terminal.   The
  975.      files  a user desires to substitute for are given as command
  976.      line arguments preceded by a special flag.   The  flags  for
  977.  
  978.  
  979.                               -12-
  980.  
  981.  
  982.  
  983.  
  984. FILE 5                       7/31/79                       FILE 5
  985.  
  986.  
  987.      reassigned files are:
  988.  
  989.                     <infile
  990.                     >outfile
  991.                     >>outfile  (for appending)
  992.                     ?errfile
  993.                     ??errfile  (for appending)
  994.  
  995.      where  'infile',  'outfile', and 'errfile' would be replaced
  996.      with the name of the file desired.  You should be  aware  of
  997.      these  file  substitution  capabilities, although they won't
  998.      be completely  operational  until  you  bring  up  the  file
  999.      manipulation primitives.
  1000.  
  1001. NEW PRIMITIVES TO WRITE
  1002.      Getarg - pick up command line arguments
  1003.      delarg - delete argument number 'n'
  1004.      (or, if possible, simply change 'makarg')
  1005.  
  1006. OTHER PRIMITIVES USED
  1007.      Initst, endst, putch, getch, remark
  1008.  
  1009. ROUTINES NEEDED FROM OTHER TOOLS
  1010.      The symbols file and library routines from file 4
  1011.      #-t-    file5.c                     3225   local    01/07/81
  1012.      15:36:55  #-h-    file6.c                      3702    local
  1013.      01/07/81  15:36:56
  1014.  
  1015.  
  1016.  
  1017.  
  1018.  
  1019.  
  1020.  
  1021.  
  1022.  
  1023.  
  1024.  
  1025.  
  1026.  
  1027.  
  1028.  
  1029.  
  1030.  
  1031.  
  1032.  
  1033.  
  1034.  
  1035.  
  1036.  
  1037.  
  1038.  
  1039.  
  1040.                               -13-
  1041.  
  1042.  
  1043.  
  1044.  
  1045. FILE 6                       7/31/80                       FILE 6
  1046.  
  1047.  
  1048.           THE CAT TOOL FOR TESTING THE FILE PRIMITIVES
  1049.                        Open, Create, Close
  1050.               Getch, Getlin, Putch, Putlin, Remark
  1051.  
  1052.  
  1053. DESCRIPTION
  1054.      Now  is  the time to begin developing your file manipulation
  1055.      primitives.  The 'cat' (i.e. concatenate  =  copy)  tool  is
  1056.      provided for testing your versions.
  1057.  
  1058.      This  is  the  most  critical step in the dσvelopment of the
  1059.      tools  at  your  site.   The  file  primitives   provide   a
  1060.      mechanism   for  attaching  to  files  from  within  running
  1061.      programs.  Many  operating  systems  already  provide  these
  1062.      utilities.   In  this  case you simply need to design ratfor
  1063.      interfaces  to  them.    However,   more   likely   is   the
  1064.      possibility  that your operating system provides few or none
  1065.      of the capabilities you will need.
  1066.  
  1067.      First, attempt  to  get  cat  to  run  using  the  temporary
  1068.      primitives  open,  create,  close, getch, putch, and remark.
  1069.      Look at the code for these primitives  to  get  an  idea  of
  1070.      what  they should be doing.  Notice that 'open' and 'create'
  1071.      simply set up a  particular  fortran  unit  for  reading  or
  1072.      writing.   They  assume you have assigned (in some manner) a
  1073.      file to these particular units.  When  you  write  your  own
  1074.      primitives,  you  must be able to associate a file name with
  1075.      an IO channel, and set it  up  for  reading  and/or  writing
  1076.      from within a running program.
  1077.  
  1078.      Read  the  design  specifications (Section 2 of this manual)
  1079.      for open, create, close, getch, and putch.   Then  sit  down
  1080.      and  carefully think through exactly what your versions will
  1081.      have to do.  For instance, if you want to be able to  handle
  1082.      local  character  sets  as  well as ascii, you will probably
  1083.      have to do your own block IO.  Remember, too, that you  will
  1084.      need  a  certain  amount  of random IO capabilities when you
  1085.    á bring up the editor so  you  might  have  a  glance  at  the
  1086.      descriptions for seek and note.
  1087.  
  1088.      You  will  also  have to teach 'remark' to find the end of a
  1089.      hollerith array.  If your system provides  this  capability,
  1090.      fine.   Otherwise,  have  'remark'  look for a period (.) as
  1091.      the end marker for the string.  All hollerith arrays in  the
  1092.      tools source code end with a dot.
  1093.  
  1094.      You  will  probably  have  to  set some limit to the maximum
  1095.      number of files which can be open at a time.  10 - 15  seems
  1096.      to be a good range.
  1097.  
  1098. CHANGES YOU MIGHT HAVE TO MAKE
  1099.  
  1100.  
  1101.                               -14-
  1102.  
  1103.  
  1104.  
  1105.  
  1106. FILE 6                       7/31/80                       FILE 6
  1107.  
  1108.  
  1109.      Extract  the  documentation,  and  copy  the general symbols
  1110.      file onto the front of the source code.
  1111.  
  1112.      Insert into 'initst' any initialization that must  be  done.
  1113.      Also,  insert  into  'endst' the code necessary to close any
  1114.      files that have been opened.  It's best to do this  even  if
  1115.      your  system  automatically closes all files at the end of a
  1116.      job.
  1117.  
  1118.      You will most certainly have a number of symbol  definitions
  1119.      to  create  for  your  primitives.   You  might like to keep
  1120.      these separate from  the  general  definitions,  on  a  file
  1121.      which can be "included" when necessary.
  1122.  
  1123.      You  will  need  to  do  quite  a  lot  of  testing  on your
  1124.      primitives.  Make sure reads on empty files work  correctly;
  1125.      make  sure  you  can create a file that already exists; and,
  1126.      test all the boundary conditions you can think of.
  1127.  
  1128.      Plan  on  at  least  one  or  two  major  rewrites  of  your
  1129.      primitives  in  the  future.  Don't try for great efficiency
  1130.      right now, just get something that works.
  1131.  
  1132. NEW PRIMITIVES TO WRITE
  1133.      Open - open an existing file for reading, writing, or both
  1134.      create - create a new file or overwrite an existing one
  1135.      close - close (detach) a file
  1136.      getch - read a character from a file
  1137.      putch - write a character onto a file
  1138.      remark - write a hollerith string to ERROUT
  1139.  
  1140. OTHER PRIMITIVES USED
  1141.      Initst
  1142.      endst
  1143.      getarg
  1144.  
  1145. ROUTINES NEEDED FROM OTHER TOOLS
  1146.      You can use any of the library routines provided on file 4.
  1147.      inmap and outmap from file 2
  1148.      #-t-   file6.c                     3702   local     01/07/81
  1149.      15:36:56   #-h-    file7.c                       950   local
  1150.      01/07/81  15:36:57
  1151.  
  1152.  
  1153.  
  1154.  
  1155.  
  1156.  
  1157.  
  1158.  
  1159.  
  1160.  
  1161.  
  1162.                               -15-
  1163.  
  1164.  
  1165.  
  1166.  
  1167. File 7                       7/31/80                       File 7
  1168.  
  1169.  
  1170.                          FILE INSERTION
  1171.                            INCLUD Tool
  1172.  
  1173.  
  1174. DESCRIPTION
  1175.      You are actually now ready to bring up the ratfor in  ratfor
  1176.      compiler  itself.   However, your task will be easier if you
  1177.      implement the 'includ' tool first so  that  you  can  easily
  1178.      include  the common blocks needed in the preprocessor source
  1179.      code.
  1180.  
  1181.      This file will also be a good test for your primitives.
  1182.  
  1183. CHANGES YOU MIGHT HAVE TO MAKE
  1184.      Remove  the  documentation  and  copy  the  general   symbol
  1185.      definitions   file   to   the  beginning  of  includ  before
  1186.      compiling it.
  1187.  
  1188.      Adjust  the  symbol  MAXOFILES   in   the   general   symbol
  1189.      definitions  to  match  the  maximum  number of opened files
  1190.      allowed by your primitives.
  1191.  
  1192. NEW PRIMITIVES TO WRITE
  1193.      None
  1194.  
  1195. OTHER PRIMITIVES USED
  1196.      open
  1197.      close
  1198.      getlin
  1199.      remark
  1200.      getarg
  1201.      initst
  1202.      endst
  1203.  
  1204. ROUTINES NEEDED FROM OTHER TOOLS
  1205.      Library routines from file 4
  1206.      #-t-   file7.c                      950   local     01/07/81
  1207.      15:36:57   #-h-    file8.c                      2002   local
  1208.      01/07/81  15:36:58
  1209.  
  1210.  
  1211.  
  1212.  
  1213.  
  1214.  
  1215.  
  1216.  
  1217.  
  1218.  
  1219.  
  1220.  
  1221.  
  1222.  
  1223.                               -16-
  1224.  
  1225.  
  1226.  
  1227.  
  1228. File 8                       7/31/80                       File 8
  1229.  
  1230.  
  1231.                        RATFOR PREPROCESSOR
  1232.  
  1233.  
  1234. DESCRIPTION
  1235.      File 8 contains  the  symbol  definitions,  included  common
  1236.      blocks,  and  source code for the ratfor preprocessor.  This
  1237.      version is one developed from the original by  David  Hanson
  1238.      of  the  University  of  Arizona and enhanced by Joe Sventek
  1239.      and Debbie Scherrer  of  Lawrence  Berkeley  Laboratory  and
  1240.      Allen  Akin  of  the  Georgia  Institute  of Technology.  It
  1241.      includes a hash table  for  searching  through  definitions,
  1242.      plus  a full macro processor, the 'string' declaration, long
  1243.      variable  names,   and  a  few  other  goodies.   If  you've
  1244.      brought  up  'includ', extract the common blocks onto a file
  1245.      named 'commons'.  If you don't have  'includ',  you'll  have
  1246.      to insert the common blocks by hand.
  1247.  
  1248. CHANGES YOU MIGHT HAVE TO MAKE
  1249.      This  version of ratfor automatically opens and includes the
  1250.      file containing the general  symbol  definitions.   Set  the
  1251.      definition  STDEFNS  in  the  source code to the name of the
  1252.      file you are using for your symbols.  (If the  file  resides
  1253.      on  a  particular directory, don't forget to include that in
  1254.      the filename.) For example,
  1255.  
  1256.                        define(STDENFS,"ratdef")
  1257.  
  1258.      (The quotes must  be  included.)  If  you  don't  want  this
  1259.      feature, set the definition to:
  1260.  
  1261.                           define(STDEFNS,"")
  1262.  
  1263.      Take  a  final  look  at 'remark' in your primitives to make
  1264.      sure you've taught it to look for a period at the end  of  a
  1265.      quoted hollerith string.
  1266.  
  1267.      The  major problems you will probably run into are character
  1268.      sets.  If you can't pass the braces '{' and '}' in, you  can
  1269.      use  '[' and ']' respectively.  If your fortran compiler can
  1270.      only process  upper  case  characters,  set  the  definition
  1271.      UPPERC this way:
  1272.  
  1273.                            define(UPPERC,)
  1274.  
  1275.      Look  at  'inmap'  and  'outmap'  for  any  other  character
  1276.      problems you run into.
  1277.  
  1278. NEW PRIMITIVES TO WRITE
  1279.      None
  1280.  
  1281. OTHER PRIMITIVES USED
  1282.  
  1283.  
  1284.                               -17-
  1285.  
  1286.  
  1287.  
  1288.  
  1289. File 8                       7/31/80                       File 8
  1290.  
  1291.  
  1292.      open
  1293.      close
  1294.      getarg
  1295.      getch
  1296.      putch
  1297.      remark
  1298.      initst
  1299.      endst
  1300.  
  1301. ROUTINES NEEDED FROM OTHER TOOLS
  1302.      Library routines
  1303.      #-t-   file8.c                     2002   local     01/07/81
  1304.      15:36:58   #-h-    edin.c                          0   local
  1305.      01/07/81   15:36:59  #-t-   edin.c                         0
  1306.      local        01/07/81       15:36:59      #-h-       file9.c
  1307.      3076  local   01/07/81  15:36:59
  1308.  
  1309.  
  1310.  
  1311.  
  1312.  
  1313.  
  1314.  
  1315.  
  1316.  
  1317.  
  1318.  
  1319.  
  1320.  
  1321.  
  1322.  
  1323.  
  1324.  
  1325.  
  1326.  
  1327.  
  1328.  
  1329.  
  1330.  
  1331.  
  1332.  
  1333.  
  1334.  
  1335.  
  1336.  
  1337.  
  1338.  
  1339.  
  1340.  
  1341.  
  1342.  
  1343.  
  1344.  
  1345.                               -18-
  1346.  
  1347.  
  1348.  
  1349.  
  1350. IN-CORE ED                   7/31/80                   IN-CORE ED
  1351.  
  1352.  
  1353.                            IN-CORE ED
  1354.  
  1355. DESCRIPTION
  1356.        At this point you are ready to bring up most of  the  rest
  1357.        of  the  tools.   There are still a few more primitives to
  1358.        write, but the  order  in  which  they  are  done  is  not
  1359.        critical.
  1360.  
  1361.        If  your system has not provided you with an editor of any
  1362.        use, you might want to bring up the  in-core  editor  now,
  1363.        to  assist  you  in  implementing  the  rest of the tools.
  1364.        You'll find it on the first part of file 11.  The  in-core
  1365.        editor  does  not  require  any more primitives than those
  1366.        you already have.
  1367.  
  1368.  
  1369.  
  1370.  
  1371.  
  1372.  
  1373.  
  1374.  
  1375.  
  1376.  
  1377.  
  1378.  
  1379.  
  1380.  
  1381.  
  1382.  
  1383.  
  1384.  
  1385.  
  1386.  
  1387.  
  1388.  
  1389.  
  1390.  
  1391.  
  1392.  
  1393.  
  1394.  
  1395.  
  1396.  
  1397.  
  1398.  
  1399.  
  1400.  
  1401.  
  1402.  
  1403.  
  1404.  
  1405.  
  1406.                               -19-
  1407.  
  1408.  
  1409.  
  1410.  
  1411. File 9                       7/31/80                       File 9
  1412.  
  1413.  
  1414.                          TEXT FORMATTING
  1415.  
  1416.  
  1417. DESCRIPTION
  1418.      This is the  source  code  for  the  text  formatter  (often
  1419.      nicknamed  'roff').   Although you are now ready to bring up
  1420.      many of  the  other  tools,  it  might  be  advantageous  to
  1421.      implement  the  text formatter first, so that it can process
  1422.      the documentation provided on File 14.  Once again,  extract
  1423.      all  the  common  block files and put them on files with the
  1424.      names indicated.
  1425.  
  1426.      You might want to use File 14 for testing.
  1427.  
  1428. CHANGES YOU MIGHT HAVE TO MAKE
  1429.      This implementation of the formatter can either  put  out  a
  1430.      line-feed  character  (control-l)  to indicate the beginning
  1431.      of a page, or it can count lines as the version in the  book
  1432.      does.   Decide  which  would  be  more  appropriate  for the
  1433.      devices you will be printing output on,  and  then,  if  you
  1434.      desire the control-l, set the following definition:
  1435.  
  1436.                          define(PAGECONTROL,)
  1437.  
  1438.      If   this  definition  doesn't  appear,  format  will  count
  1439.      lines.
  1440.  
  1441.      This formatter has a mechanism  which  allows  the  user  to
  1442.      have  the formatter stop before printing each page so that a
  1443.      new sheet of paper can  be  inserted.   The  formatter  will
  1444.      attempt  to  open a channel to the user's teletype using the
  1445.      definitions  of  TERMINAL_IN  and   TERMINAL_OUT   (in   the
  1446.      general  symbols  file) as the names of the input and output
  1447.      channels respectively.  Make sure you have set these to  the
  1448.      appropriate file names.
  1449.  
  1450.      The  primitive  'flush' will be needed to send a line to the
  1451.      user's teletype while suppressing the  carriage  return/line
  1452.      feed  sequence.  If you can't implement flush, simply send a
  1453.      NEWLINE to the output file (which will  actually  cause  the
  1454.      buffer to be flushed but won't suppress the cr/lf.)
  1455.  
  1456.      If  possible, implement the primitive 'getnow', used to pick
  1457.      up the current date and insert it into any header or  footer
  1458.      where a percent sign (%) occurs.
  1459.  
  1460.      You'll   eventually   want   to  implement  the  tool  'lpr'
  1461.      (system-dependent  and  thus  not  provided  on  the  tape).
  1462.      'Lpr'  is  a  combination of the tools 'os' (overstrike) and
  1463.      'detab', plus some sort of mechanism to  spool  a  file  for
  1464.      printing.   It  might  also have to do some carriage control
  1465.  
  1466.  
  1467.                               -20-
  1468.  
  1469.  
  1470.  
  1471.  
  1472. File 9                       7/31/80                       File 9
  1473.  
  1474.  
  1475.      to  make  sure  the  formatter   output   aligns   on   page
  1476.      boundaries.
  1477.  
  1478. NEW PRIMITIVES TO WRITE
  1479.      flush - flush output buffer
  1480.      getnow - get current date and time   (optional)
  1481.  
  1482. OTHER PRIMITIVES USED
  1483.      getarg
  1484.      open
  1485.      close
  1486.      create
  1487.      getch
  1488.      putch
  1489.      remark
  1490.      initst
  1491.      endst
  1492.  
  1493. ROUTINES NEEDED FROM OTHER TOOLS
  1494.      The library routines
  1495.      #-t-    file9.c                     3076   local    01/07/81
  1496.      15:36:59  #-h-    file10.c                     3276    local
  1497.      01/07/81  15:37:01
  1498.  
  1499.  
  1500.  
  1501.  
  1502.  
  1503.  
  1504.  
  1505.  
  1506.  
  1507.  
  1508.  
  1509.  
  1510.  
  1511.  
  1512.  
  1513.  
  1514.  
  1515.  
  1516.  
  1517.  
  1518.  
  1519.  
  1520.  
  1521.  
  1522.  
  1523.  
  1524.  
  1525.  
  1526.  
  1527.  
  1528.                               -21-
  1529.  
  1530.  
  1531.  
  1532.  
  1533. File 10                      7/31/80                      File 10
  1534.  
  1535.  
  1536.                          FILE ARCHIVING
  1537.  
  1538.  
  1539. DESCRIPTION
  1540.      This  is  the source code for 'ar', the file archiving tool.
  1541.      The archiver is an extremely  useful  tool  for  maintaining
  1542.      source  code,  documentation,  and  files of files.  It also
  1543.      does quite a bit of IO so will be a  lovely  test  for  your
  1544.      primitives.
  1545.  
  1546.      Two  versions  of  the  archiver  have been included in this
  1547.      file.  The first  was  written  by  Allen  Akin  at  Georgia
  1548.      Tech.   It delimits archive members by preceding each with a
  1549.      header of the format:
  1550.  
  1551.                   #-h- filename size type date time
  1552.  
  1553.      and following each with a trailer exactly the  same  as  the
  1554.      header  except beginning with "#-t-".  Archives are searched
  1555.      by comparing headers and trailers.  The  size  of  the  file
  1556.      (in  characters), date and time are kept only for the user's
  1557.      convenience.  All files on this tape are maintained by  this
  1558.      archiver.
  1559.  
  1560.      The  second  version  is an enhanced version of the archiver
  1561.      described  in  "Software  Tools".   It   separates   archive
  1562.      members  with  the  same  header  as  the  Akin version, but
  1563.      relies upon  the  size  given  to  locate  the  end  of  the
  1564.      member.
  1565.  
  1566.      The  first  version  has  the  advantage  that  one can edit
  1567.      archive files directly without destroying  their  integrity.
  1568.      The  second version has the advantage that it can be adapted
  1569.      to be used with binary files.  Choose whichever you wish.
  1570.  
  1571. CHANGES YOU MIGHT HAVE TO MAKE
  1572.      The primitive 'mkuniq' is needed to generate a scratch  file
  1573.      name  unique  to  the  process.   This  is  needed  to avoid
  1574.      conflicts when several users are logged in  under  the  same
  1575.      account  or  directory.   The  archiver  passes  a string of
  1576.      characters to 'mkuniq', which in turn might append  to  them
  1577.      the  process  ID  or  some  other unique identifier.  If you
  1578.      cannot pick up a process ID or cannot generate  unique  file
  1579.      names  in any way,  or if multiple users aren't a problem on
  1580.      your system,  simply  have  'mkuniq'  return  the  character
  1581.      string passed to it.
  1582.  
  1583.      The  primitive  'remove'  is used to delete the scratch file
  1584.      after it has been used.  Read the specifications in  Section
  1585.      2 for implementation details.
  1586.  
  1587.  
  1588.  
  1589.                               -22-
  1590.  
  1591.  
  1592.  
  1593.  
  1594. File 10                      7/31/80                      File 10
  1595.  
  1596.  
  1597.      The  library  routine  'amove'  is  used to copy the archive
  1598.      scratch file back to the original  after  all  changes  have
  1599.      been  made.   It  is  currently implemented as a copy-remove
  1600.      operation, but if your system provides  a  renaming  feature
  1601.      you should use that instead.
  1602.  
  1603.      You  might have a look at the routine 'gettyp'.  'Gettyp' is
  1604.      a  function   which   determines   a   files's   type--local
  1605.      character,  ascii, or binary.  This information is stored in
  1606.      the archive header only for   the  user's  convenience.   In
  1607.      its  current form, 'gettyp' returns the file type LOCAL.  If
  1608.      your system has a way for you to determine  a  file's  type,
  1609.      you  might  want  to  teach  'gettyp'  to return the correct
  1610.      information.  ('Gettyp' is also needed by the shell, if  you
  1611.      intend to bring that up.)
  1612.  
  1613. NEW PRIMITIVES TO WRITE
  1614.      remove - remove a file from the file system
  1615.      amove - move (rename) a file   (optional)
  1616.      mkuniq - get scratch file name  (optional)
  1617.      gettyp - determine a file's type (character or binary)   (Optional)
  1618.  
  1619. OTHER PRIMITIVES USED
  1620.      getarg
  1621.      getnow          (optional)
  1622.      open
  1623.      create
  1624.      close
  1625.      getch
  1626.      putch
  1627.      remark
  1628.      initst
  1629.      endst
  1630.  
  1631. ROUTINES NEEDED FROM OTHER TOOLS
  1632.      The library routines
  1633.      #-t-    file10.c                    3276   local    01/07/81
  1634.      15:37:01  #-h-    file11.c                     1709    local
  1635.      01/07/81  15:37:02
  1636.  
  1637.  
  1638.  
  1639.  
  1640.  
  1641.  
  1642.  
  1643.  
  1644.  
  1645.  
  1646.  
  1647.  
  1648.  
  1649.  
  1650.                               -23-
  1651.  
  1652.  
  1653.  
  1654.  
  1655. File 11                      7/31/80                      File 11
  1656.  
  1657.  
  1658.                            The Editor
  1659.  
  1660.  
  1661. DESCRIPTION
  1662.      Two  versions  of  the  editor  have  been  included on this
  1663.      file.  The first version is  the  in-core  editor  from  the
  1664.      "Software   Tools"   book.    It   is   provided  for  those
  1665.      unfortunates  who  cannot  implement  random  IO  on   their
  1666.      systems.   If you can implement random IO, choose the second
  1667.      version.
  1668.  
  1669. CHANGES YOU MIGHT HAVE TO MAKE
  1670.      You'll have to implement the two random IO  primitives--seek
  1671.      and  note.   Read  their  descriptions carefully.  Two words
  1672.      have been allotted for the address returned by 'note'.   You
  1673.      may  not  need this many but several systems do so space has
  1674.      been allowed for them.
  1675.  
  1676.      You will probably be interested in fine-tuning the editor  a
  1677.      bit  for  your  own system.  On the random access version of
  1678.      the editor, look at the  routines  'setb'  and  'getb'--they
  1679.      pick  up  and  store  information in the line pointer array.
  1680.      Four items of information are kept about each line:  pointer
  1681.      to  next  line,  pointer  to  last  line,  mark  (for global
  1682.      commands), and  seek  address  (2  words).   Each  piece  of
  1683.      information  is  kept in a separate word, but you might like
  1684.      to pack them into fewer bits.  If you do  this,  adjust  the
  1685.      symbol  'BUFENT',  which sets the number of words needed for
  1686.      each line.
  1687.  
  1688.      You'll probably want to  adjust  the  symbol  MAXBUF,  which
  1689.      determines the maximum length of the line pointer array.
  1690.  
  1691. NEW PRIMITIVES TO WRITE
  1692.      note - determine current file position
  1693.      seek - move read/write pointer to position specified
  1694.  
  1695. OTHER PRIMITIVES USED
  1696.      getarg
  1697.      getch
  1698.      open
  1699.      create
  1700.      putch
  1701.      remark
  1702.      remove
  1703.      mkuniq
  1704.      initst
  1705.      endst
  1706.  
  1707. ROUTINES NEEDED FROM OTHER TOOLS
  1708.      The library routines
  1709.  
  1710.  
  1711.                               -24-
  1712.  
  1713.  
  1714.  
  1715.  
  1716. File 11                      7/31/80                      File 11
  1717.  
  1718.  
  1719.      #-t-    file11.c                    1709   local    01/07/81
  1720.      15:37:02  #-h-    file12.c                      989    local
  1721.      01/07/81  15:37:03
  1722.  
  1723.  
  1724.  
  1725.  
  1726.  
  1727.  
  1728.  
  1729.  
  1730.  
  1731.  
  1732.  
  1733.  
  1734.  
  1735.  
  1736.  
  1737.  
  1738.  
  1739.  
  1740.  
  1741.  
  1742.  
  1743.  
  1744.  
  1745.  
  1746.  
  1747.  
  1748.  
  1749.  
  1750.  
  1751.  
  1752.  
  1753.  
  1754.  
  1755.  
  1756.  
  1757.  
  1758.  
  1759.  
  1760.  
  1761.  
  1762.  
  1763.  
  1764.  
  1765.  
  1766.  
  1767.  
  1768.  
  1769.  
  1770.  
  1771.  
  1772.                               -25-
  1773.  
  1774.  
  1775.  
  1776.  
  1777. File 12                      7/31/80                      File 12
  1778.  
  1779.  
  1780.                            OTHER TOOLS
  1781.  
  1782.  
  1783. DESCRIPTION
  1784.      Here  are  most of the rest of the tools, each included as a
  1785.      separate member of an archive.
  1786.  
  1787.      Note that a few of  the  tools  require  common  blocks  and
  1788.      definitions  already  provided  for other tools on the tape.
  1789.      We've included them twice, but  make  sure  that  if  you've
  1790.      made  any  changes  to  the  previous ones, you change these
  1791.      copies as well.
  1792.  
  1793. CHANGES YOU MIGHT HAVE TO MAKE
  1794.      If you've implemented your primitives  properly,  all  these
  1795.      tools should come up with few problems.
  1796.  
  1797.      Finish  up  any  primitives you haven't written, reading the
  1798.      design specifications in Section 2.
  1799.  
  1800. NEW PRIMITIVES TO WRITE
  1801.      whatever you haven't completed (except 'spawn')
  1802.  
  1803. OTHER PRIMITIVES USED
  1804.      getarg
  1805.      getch
  1806.      putch
  1807.      remark
  1808.      open
  1809.      close
  1810.      create
  1811.      initst
  1812.      getnow
  1813.      isatty
  1814.      endst
  1815.      remove
  1816.      mkuniq
  1817.  
  1818. ROUTINES NEEDED FROM OTHER TOOLS
  1819.      The library routines
  1820.      #-t-   file12.c                     989   local     01/07/81
  1821.      15:37:03   #-h-    file13.c                     1849   local
  1822.      01/07/81  15:37:03
  1823.  
  1824.  
  1825.  
  1826.  
  1827.  
  1828.  
  1829.  
  1830.  
  1831.  
  1832.  
  1833.                               -26-
  1834.  
  1835.  
  1836.  
  1837.  
  1838. File 13                      6/9/79                       File 13
  1839.  
  1840.  
  1841.                             The Shell
  1842.  
  1843.  
  1844.  
  1845. DESCRIPTION
  1846.      Ah, here is the piece-de-resistence:  the UNIX-like shell.
  1847.  
  1848. CHANGES YOU MIGHT HAVE TO MAKE
  1849.      You'll have to implement the primitive  'spawn'.   Read  the
  1850.      description  in  Secion  2  very carefully.  You may have to
  1851.      alter your original version of 'getarg'   (or  'makarg')  so
  1852.      that  it  can  read  arguments  passed  via 'spawn'.  If you
  1853.      cannot implement background processes, disable the  'doampr'
  1854.      routine.
  1855.  
  1856.      Have  a look at the library routine 'prompt'.  It is used to
  1857.      output a string (such as  '%  ')  to  the  user's  terminal,
  1858.      suppressing   the  carriage-return/line-feed  sequence.   It
  1859.      then reads input from the  user.   'Prompt'  expects  to  be
  1860.      able  to  write  to  the  user's  terminal  via  the channel
  1861.      descriptor passed to it.  If this cannot  be  done  on  your
  1862.      system,  adjust  prompt  to  open  a separate channel to the
  1863.      teletype.
  1864.  
  1865.      If you haven't already implemented 'gettyp',  try  it  again
  1866.      now.   The  shell  uses  'gettyp'  to  determine  whether  a
  1867.      command is a binary  executable  file  or  character  script
  1868.      file  containing further commands.  If you absolutely cannot
  1869.      find a way to tell character  files  from  executable  code,
  1870.      then  the user will have to explicitly execute shell scripts
  1871.      by saying:
  1872.  
  1873.                        % sh scriptname args ...
  1874.  
  1875.      You might also want to look at the routine  'loccom',  which
  1876.      searches  a  series of directories when attempting to locate
  1877.      commands.  You might want to adjust it for your system.
  1878.  
  1879. NEW PRIMITIVES TO WRITE
  1880.      spawn - execute a subtask
  1881.      gettyp - determine type of file (character or binary)
  1882.      prompt - issue prompt to user and read input
  1883.  
  1884. OTHER PRIMITIVES USED
  1885.      close
  1886.      create
  1887.      delarg
  1888.      endst
  1889.      getarg
  1890.      getch, getlin
  1891.      initst
  1892.  
  1893.  
  1894.                               -27-
  1895.  
  1896.  
  1897.  
  1898.  
  1899. File 13                      6/9/79                       File 13
  1900.  
  1901.  
  1902.      open
  1903.      putch, putlin, remark
  1904.      remove
  1905.      mkuniq
  1906.  
  1907. ROUTINES NEEDED FROM OTHER TOOLS
  1908.      The library routines #-t-   file13.c                    1849
  1909.      local             01/07/81            15:37:03          #-h-
  1910.      file14.c                    697  local   01/07/81  15:37:04
  1911.  
  1912.  
  1913.  
  1914.  
  1915.  
  1916.  
  1917.  
  1918.  
  1919.  
  1920.  
  1921.  
  1922.  
  1923.  
  1924.  
  1925.  
  1926.  
  1927.  
  1928.  
  1929.  
  1930.  
  1931.  
  1932.  
  1933.  
  1934.  
  1935.  
  1936.  
  1937.  
  1938.  
  1939.  
  1940.  
  1941.  
  1942.  
  1943.  
  1944.  
  1945.  
  1946.  
  1947.  
  1948.  
  1949.  
  1950.  
  1951.  
  1952.  
  1953.  
  1954.  
  1955.                               -28-
  1956.  
  1957.  
  1958.  
  1959.  
  1960. File 14                      7/31/80                      File 14
  1961.  
  1962.  
  1963.                           Documentation
  1964.  
  1965.  
  1966. DESCRIPTION
  1967.      Here  is  the  input   source   for   the   software   tools
  1968.      programmer's  manual, in a format designed to be sent to the
  1969.      text formatter.
  1970.  
  1971.      Notice  that  it  is  an  archived  file.   To  produce  the
  1972.      documentation for, say, ratfor, the user would specify:
  1973.  
  1974.                      ar p manual ratfor | format
  1975.  
  1976.      (Or, "ar p manual ratfor | format | crt")
  1977.  
  1978.  
  1979.      To print the entire manual, the user might say:
  1980.  
  1981.                       ar p manual | format | lpr
  1982.  
  1983.      (where  'lpr'  is  a  combination  of 'os' and 'detab', plus
  1984.      whatever is necessary to spool a file to the printer).
  1985.  
  1986. CHANGES YOU MIGHT HAVE TO MAKE
  1987.      Change       anything        you'd        like.         #-t-
  1988.      file14.c                     697  local   01/07/81  15:37:04
  1989.      #-h-   file15.c                     764   local     01/07/81
  1990.      15:37:05
  1991.  
  1992.  
  1993.  
  1994.  
  1995.  
  1996.  
  1997.  
  1998.  
  1999.  
  2000.  
  2001.  
  2002.  
  2003.  
  2004.  
  2005.  
  2006.  
  2007.  
  2008.  
  2009.  
  2010.  
  2011.  
  2012.  
  2013.  
  2014.  
  2015.  
  2016.                               -29-
  2017.  
  2018.  
  2019.  
  2020.  
  2021. File 15                      7/31/80                      File 15
  2022.  
  2023.  
  2024.                          Optional Tools
  2025.  
  2026.  
  2027. DESCRIPTION
  2028.      This  section  contains  tools which may require additional,
  2029.      special-purpose primitives, or  which  have  been  submitted
  2030.      for  distribution  without  extensive testing or alteration.
  2031.      These tools have  been  included  on  the  tape  exactly  as
  2032.      submitted.  Each is included as a member of the archive.
  2033. èCHANGES YOU MIGHT HAVE TO MAKE
  2034.      ????
  2035.  
  2036. NEW PRIMITIVES TO WRITE
  2037.      Hopefully, each tool will provide not only documentation for the
  2038.      tool itself, but also instructions for writing any necessary
  2039.      new primitives.
  2040.  
  2041. OTHER PRIMITIVES USED
  2042.      probably all of them
  2043.  
  2044. ROUTINES NEEDED FROM OTHER TOOLS
  2045.      Who knows...
  2046.      #-t-    file15.c                     764   local    01/07/81
  2047.      15:37:05  #-h-    file16.c                      415    local
  2048.      01/07/81  15:37:06
  2049.  
  2050.  
  2051.  
  2052.  
  2053.  
  2054.  
  2055.  
  2056.  
  2057.  
  2058.  
  2059.  
  2060.  
  2061.  
  2062.  
  2063.  
  2064.  
  2065.  
  2066.  
  2067.  
  2068.  
  2069.  
  2070.  
  2071.  
  2072.  
  2073.  
  2074.  
  2075.  
  2076.                               -30-
  2077.  
  2078.  
  2079.  
  2080.  
  2081. File 16                      7/31/80                      File 16
  2082.  
  2083.  
  2084.                        Spelling Dictionary
  2085.  
  2086.  
  2087. DESCRIPTION
  2088.      Here  are about 42,000 words for you.  We use the dictionary
  2089.      for our 'spell' tool, but it's also useful for  game  shows,
  2090.      cross-word puzzles, etc.
  2091.  
  2092.      The  dictionary  is  in  sort  order  (of course), all lower
  2093.      case, and with one word per line.
  2094.  
  2095. CHANGES YOU MIGHT HAVE TO MAKE
  2096.      Add    to    it    all    you    like.     #-t-     file16.c
  2097.      415        local         01/07/81        15:37:06       #-h-
  2098.      overview                   1478  local   01/07/81  15:43:13
  2099.  
  2100.  
  2101.  
  2102.  
  2103.  
  2104.  
  2105.  
  2106.  
  2107.  
  2108.  
  2109.  
  2110.  
  2111.  
  2112.  
  2113.  
  2114.  
  2115.  
  2116.  
  2117.  
  2118.  
  2119.  
  2120.  
  2121.  
  2122.  
  2123.  
  2124.  
  2125.  
  2126.  
  2127.  
  2128.  
  2129.  
  2130.  
  2131.  
  2132.  
  2133.  
  2134.  
  2135.  
  2136.  
  2137.                               -31-
  2138.  
  2139.  
  2140.  
  2141.  
  2142.  
  2143.  
  2144.  
  2145.  
  2146.  
  2147.  
  2148.  
  2149.  
  2150.  
  2151.  
  2152.  
  2153.  
  2154.  
  2155.  
  2156.  
  2157.  
  2158.  
  2159.  
  2160.  
  2161.             SPECIFICATIONS FOR SYSTEM-DEPENDENT PRIMITIVES
  2162.  
  2163.  
  2164.  
  2165.  
  2166.      This part of the cookbook contains  detailed  specifications
  2167.      to  be used in the design and implementation of the software
  2168.      tools system-dependent primitives.
  2169.  
  2170.  
  2171.  
  2172.  
  2173.  
  2174.  
  2175.  
  2176.  
  2177.  
  2178.  
  2179.  
  2180.  
  2181.  
  2182.  
  2183.  
  2184.  
  2185.  
  2186.  
  2187.  
  2188.  
  2189.  
  2190.  
  2191.  
  2192.  
  2193.  
  2194.  
  2195.  
  2196.  
  2197.  
  2198.                               -32-
  2199.  
  2200.  
  2201.  
  2202.  
  2203. PRIMITIVES                   1/8/81                    PRIMITIVES
  2204.  
  2205.  
  2206.               OVERVIEW OF SOFTWARE TOOLS PRIMITIVES
  2207.  
  2208.  
  2209.  (The '#' indicates that, on some systems,  the  routine  may  be
  2210. written in terms of the other primitives.)
  2211.  
  2212.  
  2213.  
  2214. FILE ACCESS
  2215.        open - open an existing file for reading, writing, or both
  2216.        create - create a new file (or overwrite an existing one)
  2217.        close - close (detach) a file
  2218.        remove - remove a file from the file system
  2219.       #amove - move (rename) file1 to file2
  2220.        isatty - determine if file is a teletype/CRT device
  2221.        gettyp - determine type of file (character or binary)
  2222.  
  2223. I/O
  2224.        getch - read character from file
  2225.       #getlin - read next line from file
  2226.        putch - write character to file
  2227.       #putlin - write a line to a file
  2228.       #prompt - write to/read from teletype; suppress cr/lf
  2229.        remark - print single-line message
  2230.        seek - move read/write pointer
  2231.        note - determine file position of next record to be read/written
  2232.        readf - read 'n' bytes/words from file
  2233.        writef - write 'n' bytes/words to file
  2234.        flush - flush output buffer
  2235.  
  2236. MISCELLANEOUS
  2237.        getarg - get command line arguments
  2238.        delarg - delete command line argument 'n'
  2239.        initst - initialize all standard files and common variables
  2240.        endst - close all open files and terminate program
  2241.        mkuniq - generate unique file name
  2242.        getnow - get current date and time
  2243.        spawn - execute subtask
  2244.        #-t-  overview                   1478  local   01/07/81  15:43:13
  2245.        #-h-  amove                      1399  local   01/07/81  22:51:01
  2246.  
  2247.  
  2248.  
  2249.  
  2250.  
  2251.  
  2252.  
  2253.  
  2254.  
  2255.  
  2256.  
  2257.  
  2258.  
  2259.                               -33-
  2260.  
  2261.  
  2262.  
  2263.  
  2264. AMOVE (2)                   11/10/78                    AMOVE (2)
  2265.  
  2266.  
  2267. NAME
  2268.        amove - move (rename) file1 to file2
  2269.  
  2270. SYNOPSIS
  2271.        stat = amove (name1, name2)
  2272.  
  2273.        character name1(FILENAMESIZE), name2(FILENAMESIZE)
  2274.        integer stat returned as OK/ERR
  2275.  
  2276. DESCRIPTION
  2277.        Amove  moves  the  contents of the file specified by name1
  2278.        to the file specified  by  name2.   It  is  essentially  a
  2279.        renaming  of  the  file.   If  the  file  could  be  moved
  2280.        properly, OK is returned.  If there were  problems  either
  2281.        creating  the  new  file  or  deleting the old one, ERR is
  2282.        returned.
  2283.  
  2284.        Both file names are  ascii  character  strings  terminated
  2285.        with an EOS marker.
  2286.  
  2287.        The  files need not be connected to the running program to
  2288.        be renamed.
  2289.  
  2290. IMPLEMENTATION
  2291.        Amove primarily exists to change the name of a file,  such
  2292.        as  when  moving  the  archive  scratch  file  back to the
  2293.        original.  If possible, this should be implemented with  a
  2294.        "rename"  primitive  in  the  local  operating system.  If
  2295.        this  capability   isn't   available,   amove   could   be
  2296.        implemented as a copy/delete combination.
  2297.  
  2298.        Amoves  from  different  devices  will most likely have to
  2299.        be  implemented as copy/remove operations.
  2300.  
  2301.        If the system  supports  naming  conventions  for  devices
  2302.        such  as  TTYs,  then  amoving a file to a TTY should copy
  2303.        the file to the TTY and then remove it.
  2304.  
  2305. SEE ALSO
  2306.        fcopy, remove
  2307.  
  2308. DIAGNOSTICS
  2309.        None   #-t-    amove                        1399     local
  2310.        01/07/81   22:51:01  #-h-  close                      1088
  2311.        local   01/07/81  22:51:02
  2312.  
  2313.  
  2314.  
  2315.  
  2316.  
  2317.  
  2318.  
  2319.  
  2320.                                -1-
  2321.  
  2322.  
  2323.  
  2324.  
  2325. CLOSE (2)                   11/10/78                    CLOSE (2)
  2326.  
  2327.  
  2328. NAME
  2329.        close - close (detach) a file
  2330.  
  2331. SYNOPSIS
  2332.        call close (fd)
  2333.  
  2334.        filedes fd
  2335.  
  2336. DESCRIPTION
  2337.        Close disassociates file descriptor "fd" from  the  opened
  2338.        file  to  which it refers.  If "fd" is the only descriptor
  2339.        referring to that file, all pending I/O is  completed  and
  2340.        the  file  is closed.  If "fd" does not refer to an opened
  2341.        file, close simply returns.   "fd"  is  an  internal  file
  2342.        descriptor as returned from an open or create call.
  2343.  
  2344. IMPLEMENTATION
  2345.        Close  breaks  the  connection  between  the program and a
  2346.        file accessed via  open  or  create.   If  necessary,  the
  2347.        file's  write buffer is flushed and the end of the file is
  2348.        marked so that subsequent reads will find an  EOF.   If  a
  2349.        file  has  been  opened multiple times (that is, more than
  2350.        one internal descriptor has  been  assigned  to  a  file),
  2351.        care  is  taken  that  multiple closes will not damage the
  2352.        file.
  2353.  
  2354. SEE ALSO
  2355.        open, create, endst
  2356.  
  2357. DIAGNOSTICS
  2358.        If the file descriptor is in  error,  the  routine  simply
  2359.        returns.   #-t-   close                       1088   local
  2360.        01/07/81  22:51:02 #-h-   create                      1355
  2361.        local   01/07/81  22:51:03
  2362.  
  2363.  
  2364.  
  2365.  
  2366.  
  2367.  
  2368.  
  2369.  
  2370.  
  2371.  
  2372.  
  2373.  
  2374.  
  2375.  
  2376.  
  2377.  
  2378.  
  2379.  
  2380.  
  2381.                                -1-
  2382.  
  2383.  
  2384.  
  2385.  
  2386. CREATE (2)                  11/10/78                   CREATE (2)
  2387.  
  2388.  
  2389. NAME
  2390.        create - create a new file (or overwrite an existing one)
  2391.  
  2392. SYNOPSIS
  2393.        fd = create (name, access)
  2394.  
  2395.        character name(FILENAMESIZE)
  2396.        integer access
  2397.        filedes fd - returned as a file descriptor/ERR
  2398.  
  2399. DESCRIPTION
  2400.        Create  creates  a  new  file  whose  name is contained in
  2401.        "name" and then opens it for I/O according  to  the  value
  2402.        of  "mode",  as  if open had been called (see "open").  If
  2403.        the file already exists, it is truncated and prepared  for
  2404.        overwriting.
  2405.  
  2406.        If   the   creation   succeeded,  create  returns  a  file
  2407.        descriptor  which  is  used  to  refer  to  the  file   in
  2408.        subsequent  I/O  calls.  If the file could not be created,
  2409.        ERR is returned.
  2410.  
  2411. IMPLEMENTATION
  2412.        Create creates a new file from within  a  running  program
  2413.        and  connects the external name of the file to an internal
  2414.        identifier which is then usable in  subsequent  subroutine
  2415.        calls.   If  the  file  already exists, the old version is
  2416.        removed or truncated to 0  length  and  overwritten.   All
  2417.        other functions are similar to open.
  2418.  
  2419.        On  some systems a default character type (ASCII or LOCAL)
  2420.        is assigned to a newly-created file.
  2421.  
  2422. SEE ALSO
  2423.        open, close
  2424.  
  2425. DIAGNOSTICS
  2426.        Theáfunction returns ERR if the file could not be  created
  2427.        or  if  there  are  already  too  many  files  open.  #-t-
  2428.        create                        1355     local      01/07/81
  2429.        22:51:03   #-h-   delarg                       675   local
  2430.        01/07/81  22:53:16
  2431.  
  2432.  
  2433.  
  2434.  
  2435.  
  2436.  
  2437.  
  2438.  
  2439.  
  2440.  
  2441.  
  2442.                                -1-
  2443.  
  2444.  
  2445.  
  2446.  
  2447. DELARG (2)                   6/5/79                    DELARG (2)
  2448.  
  2449.  
  2450. NAME
  2451.        delarg - delete command line argument number 'n'
  2452.  
  2453. SYNOPSIS
  2454.        call delarg (n)
  2455.  
  2456.        integer n
  2457.  
  2458. DESCRIPTION
  2459.        Delarg deletes the "n"th  command  line  argument,  if  it
  2460.        exists.   After  a  successful  call  to  delarg, calls to
  2461.        getarg behave as though the  deleted  argument  had  never
  2462.        been specified.
  2463.  
  2464. IMPLEMENTATION
  2465.        Delarg  works  in conjunction with 'getarg'.  It generally
  2466.        re-orders indices to an array  holding  the  command  line
  2467.        arguments.
  2468.  
  2469. SEE ALSO
  2470.        getarg, initst
  2471.  
  2472. DIAGNOSTICS
  2473.        If  argument  'n'  does  not exist, delarg simply returns.
  2474.        #-t-  delarg                       675   local    01/07/81
  2475.        22:53:16   #-h-   endst                        846   local
  2476.        01/07/81  22:53:17
  2477.  
  2478.  
  2479.  
  2480.  
  2481.  
  2482.  
  2483.  
  2484.  
  2485.  
  2486.  
  2487.  
  2488.  
  2489.  
  2490.  
  2491.  
  2492.  
  2493.  
  2494.  
  2495.  
  2496.  
  2497.  
  2498.  
  2499.  
  2500.  
  2501.  
  2502.  
  2503.                                -1-
  2504.  
  2505.  
  2506.  
  2507.  
  2508. ENDST (2)                   11/10/78                    ENDST (2)
  2509.  
  2510.  
  2511. NAME
  2512.        endst  -  close  all  open  files  and  terminate  program
  2513.        execution
  2514.  
  2515. SYNOPSIS
  2516.        call endst
  2517.  
  2518. DESCRIPTION
  2519.        Normally  called  at  the  end  of  any  ratfor program or
  2520.        program which uses the software tools primitives.   Closes
  2521.        all open files and terminates program execution.
  2522.  
  2523.        On  many  systems  a  call to endst is made automatically,
  2524.        either by the system  or  by  specifically  inserting  the
  2525.        call into code processed by the ratfor preprocessor.
  2526.  
  2527. IMPLEMENTATION
  2528.        Any  open files are closed.  If any files have been opened
  2529.        multiple times (that is, they have more than one  internal
  2530.        descriptor  assigned to them), care is taken that multiple
  2531.        closes do not damage the file.
  2532.  
  2533. SEE ALSO
  2534.        close, initst
  2535.  
  2536. DIAGNOSTICS
  2537.        None   #-t-    endst                         846     local
  2538.        01/07/81   22:53:17  #-h-  flush                       998
  2539.        local   01/07/81  22:52:26
  2540.  
  2541.  
  2542.  
  2543.  
  2544.  
  2545.  
  2546.  
  2547.  
  2548.  
  2549.  
  2550.  
  2551.  
  2552.  
  2553.  
  2554.  
  2555.  
  2556.  
  2557.  
  2558.  
  2559.  
  2560.  
  2561.  
  2562.  
  2563.  
  2564.                                -1-
  2565.  
  2566.  
  2567.  
  2568.  
  2569. FLUSH (2)                    7/24/79                    FLUSH (2)
  2570.  
  2571.  
  2572. NAME
  2573.        flush - flush output buffer for file 'fd'
  2574.  
  2575. SYNOPSIS
  2576.        call flush (fd)
  2577.  
  2578.        filedes fd
  2579.  
  2580.  
  2581. DESCRIPTION
  2582.        Flush assures that any remaining characters in the  output
  2583.        buffer  of  the file specified by "fd" are sent out to the
  2584.        file.  It is useful for sending lines to  a  teletype-like
  2585.        device  without  requiring  a  NEWLINE character, and also
  2586.        for flushing buffers after calls to "writef".
  2587.  
  2588. IMPLEMENTATION
  2589.        It is expected  that  most  software  tools  installations
  2590.        will  employ some form of buffered I/O.  Flush is intended
  2591.        to define the buffer-clearing operation that  takes  place
  2592.        before  file  closing,  and to provide a means of insuring
  2593.        that output directed to a terminal has  appeared  on  that
  2594.        terminal   (e.g.  before  obtaining  some  input  after  a
  2595.        prompt).  On systems  with  unbuffered  I/O,  flush  is  a
  2596.        no-op.
  2597.  
  2598. SEE ALSO
  2599.        prompt, writef, putch, putlin
  2600.  
  2601. DIAGNOSTICS
  2602.        None    #-t-    flush                         998    local
  2603.        01/07/81  22:52:26 #-h-   getarg                      2266
  2604.        local   01/07/81  22:53:18
  2605.  
  2606.  
  2607.  
  2608.  
  2609.  
  2610.  
  2611.  
  2612.  
  2613.  
  2614.  
  2615.  
  2616.  
  2617.  
  2618.  
  2619.  
  2620.  
  2621.  
  2622.  
  2623.  
  2624.  
  2625.                                -1-
  2626.  
  2627.  
  2628.  
  2629.  
  2630. GETARG (2)                  11/10/78                   GETARG (2)
  2631.  
  2632.  
  2633. NAME
  2634.        getarg - get command line arguments
  2635.  
  2636. SYNOPSIS
  2637.        stat = getarg (n, array, maxsize)
  2638.  
  2639.        integer n, maxsize
  2640.        character array(ARB)
  2641.        integer stat returned as length/EOF
  2642.  
  2643. DESCRIPTION
  2644.        Getarg  returns  the "n"th argument to the current program
  2645.        in the array "arg", one character per array element.   The
  2646.        argument  is  terminated  by  an EOS marker.  'Maxsize' is
  2647.        passed as  the  maximum  number  of  characters  array  is
  2648.        prepared   to  deal  with  (including  the  EOS);   getarg
  2649.        truncates the argument if necessary.  Getarg  returns  the
  2650.        length  of  the  argument in "arg" (excluding the EOS), or
  2651.        EOF if "n" specified a non-existent argument.
  2652.  
  2653.        On some systems, if "n" is zero, the name of  the  current
  2654.        program  is  returned  in  "arg"  and,  if  "n" is -1, the
  2655.        function returns the number of arguments  on  the  command
  2656.        line.
  2657.  
  2658.        Also,  on some systems, command line arguments can only be
  2659.        passed in a  single  case  (upper  or  lower).   On  these
  2660.        systems  an  escape mechanism may be necessary to indicate
  2661.        case when specifying arguments.
  2662.  
  2663. IMPLEMENTATION
  2664.  
  2665.        The implementation of 'getarg' may be quite  different  on
  2666.        different  operating  systems.   Some  systems  allow only
  2667.        upper case (or lower case) on the command line;  they  may
  2668.        limit  size;  they  may  not  even  provide  access at all
  2669.        without considerable contortions.
  2670.  
  2671.        When implementing 'getarg', the designer  should  keep  in
  2672.        mind  that  a  'delarg' will also be needed.  One possible
  2673.        design would be to create a routine 'makarg', which  would
  2674.        pick  up  the  arguments  from the system, convert them to
  2675.        ascii  strings,  handle  any   upper-lower   case   escape
  2676.        conventions,  and  store them in an array.  'Getarg' could
  2677.        then access this array, stripping off any  quoted  strings
  2678.        surrounding  the  arguments, and passing them along to the
  2679.        user.   'Delarg'  could  also  access  this   array   when
  2680.        removing reference to arguments.
  2681.  
  2682.        If  it  is  absolutely  impossible to pick up command line
  2683.        arguments from the system, 'makarg'  could  be  taught  to
  2684.  
  2685.  
  2686.                                -1-
  2687.  
  2688.  
  2689.  
  2690.  
  2691. GETARG (2)                  11/10/78                   GETARG (2)
  2692.  
  2693.  
  2694.        prompt the user for them.
  2695.  
  2696.        If   the   shell  is  implemented,  'getarg'  (or  perhaps
  2697.        'markarg') will have to be altered to  read  arguments  as
  2698.        passed from the shell.
  2699.  
  2700. SEE ALSO
  2701.        initst, delarg
  2702.  
  2703. DIAGNOSTICS
  2704.        None    #-t-    getarg                       2266    local
  2705.        01/07/81  22:53:18 #-h-   getnow                      1299
  2706.        local   01/07/81  22:53:19
  2707.  
  2708.  
  2709.  
  2710.  
  2711.  
  2712.  
  2713.  
  2714.  
  2715.  
  2716.  
  2717.  
  2718.  
  2719.  
  2720.  
  2721.  
  2722.  
  2723.  
  2724.  
  2725.  
  2726.  
  2727.  
  2728.  
  2729.  
  2730.  
  2731.  
  2732.  
  2733.  
  2734.  
  2735.  
  2736.  
  2737.  
  2738.  
  2739.  
  2740.  
  2741.  
  2742.  
  2743.  
  2744.  
  2745.  
  2746.  
  2747.                                -2-
  2748.  
  2749.  
  2750.  
  2751.  
  2752. GETNOW (2)                  09/25/80                   GETNOW (2)
  2753.  
  2754.  
  2755. NAME
  2756.        getnow - determine current date and time
  2757.  
  2758. SYNOPSIS
  2759.        subroutine getnow (now)
  2760.        integer now (7)
  2761.  
  2762. DESCRIPTION
  2763.        'Getnow'  is  used  to  query the operating system for the
  2764.        current date  and  time.   The  requested  information  is
  2765.        returned  in  a  seven-word  integer  array, where: word 1
  2766.        contains the year (e.g. 1980); word 2 contains  the  month
  2767.        (e.g.  9);  word  3  contains  the  day  (e.g. 25); word 4
  2768.        contains the hour (e.g. 13); word 5  contains  the  minute
  2769.        (e.g.  39);  word  6 contains the second (e.g. 14); word 7
  2770.        contains the millisecond (e.g. 397).
  2771.  
  2772.        The information returned by 'getnow' may be used as-is  or
  2773.        further  useful  processing  may  be  done  by 'fmtdat' or
  2774.        'wkday'.
  2775.  
  2776. IMPLEMENTATION
  2777.        Operating  systems  generally  have  some  mechanism   for
  2778.        picking  up  the current date and time.  If yours has one,
  2779.        use it.
  2780.  
  2781.        Getnow is not critical to the implementation of the  tools
  2782.        and  can  be left as a stub if the operating system cannot
  2783.        supply the needed information.
  2784.  
  2785. ARGUMENTS MODIFIED
  2786.        now
  2787.  
  2788. BUGS
  2789.        Some  systems  cannot  obtain  all  the  time  information
  2790.        described.   Array  elements that cannot be filled default
  2791.        to zero.
  2792.  
  2793. SEE ALSO
  2794.        fmtdat    (2),    wkday     (2),     date     (1)     #-t-
  2795.        getnow                        1299     local      01/07/81
  2796.        22:53:19  #-h-   getch                        988    local
  2797.        01/07/81  22:51:04
  2798.  
  2799.  
  2800.  
  2801.  
  2802.  
  2803.  
  2804.  
  2805.  
  2806.  
  2807.  
  2808.                                -1-
  2809.  
  2810.  
  2811.  
  2812.  
  2813. GETCH (2)                   11/10/78                    GETCH (2)
  2814.  
  2815.  
  2816. NAME
  2817.        getch - read character from file
  2818.  
  2819. SYNOPSIS
  2820.        c = getch (c, fd)
  2821.  
  2822.        character c
  2823.        filedes fd
  2824.  
  2825. DESCRIPTION
  2826.        Getch  reads the next character from the file specified by
  2827.        fd.  The character is returned in  ascii  format  both  as
  2828.        the  functional return and in the parameter c.  If the end
  2829.        of a line has been encountered, NEWLINE is  returned.   If
  2830.        the   end  of  the  file  has  been  encountered,  EOF  is
  2831.        returned.
  2832.  
  2833. IMPLEMENTATION
  2834.        Interspersed calls to getch and getlin work  properly.   A
  2835.        common  implementation  is to have getlin work by repeated
  2836.        calls to getch.
  2837.  
  2838.        If the input file is  not  ascii,  characters  are  mapped
  2839.        into  their  corresponding  ascii  format  via  a  routine
  2840.        called "inmap".
  2841.  
  2842.        Getch is able to  recognize  an  end-of-file  marker  from
  2843.        either a terminal or a file.
  2844.  
  2845.  
  2846. SEE ALSO
  2847.        getc, getlin, putch, putlin, readf, writef
  2848.  
  2849. DIAGNOSTICS
  2850.        None    #-t-    getch                         988    local
  2851.        01/07/81  22:51:04 #-h-   getlin                      2028
  2852.        local   01/07/81  22:51:05
  2853.  
  2854.  
  2855.  
  2856.  
  2857.  
  2858.  
  2859.  
  2860.  
  2861.  
  2862.  
  2863.  
  2864.  
  2865.  
  2866.  
  2867.  
  2868.  
  2869.                                -1-
  2870.  
  2871.  
  2872.  
  2873.  
  2874. GETLIN (2)                  11/10/78                   GETLIN (2)
  2875.  
  2876.  
  2877. NAME
  2878.        getlin - get next line from file
  2879.  
  2880. SYNOPSIS
  2881.        stat = getlin (line, fd)
  2882.  
  2883.        character line(MAXLINE)
  2884.        filedes fd
  2885.        integer stat returned as length/EOF
  2886.  
  2887. DESCRIPTION
  2888.        Getlin  reads  the  next line from the file opened on file
  2889.        descriptor "fd" into the  ascii  character  array  "line".
  2890.        Characters  are copied until a NEWLINE character (or other
  2891.        end-of-record  marker)   is   found   or   until   MAXLINE
  2892.        characters  have  been  copied.   A  NEWLINE  character is
  2893.        returned whenever an end-of-line marker  has  been  sensed
  2894.        and the entire string is termined with an EOS.
  2895.  
  2896.        If  the  line  is  longer  than  MAXLINE  characters, some
  2897.        systems truncate the line to MAXLINE, while other  systems
  2898.        return  the  remainder  of  the  line  in the next call to
  2899.        getlin.
  2900.  
  2901.        Getlin returns EOF when it encounters an end-of-file,  and
  2902.        otherwise returns the line length (excluding the EOS).
  2903.  
  2904.        Interspersed  calls  to  getlin  and getch are allowed and
  2905.        work properly.
  2906.  
  2907. IMPLEMENTATION
  2908.        Getlin reads characters either directly  from  a  file  or
  2909.        from  an  internal buffer set up when the file was opened.
  2910.        When an end-or-record is encountered  (by  whatever  means
  2911.        the  system  does that sort of thing), a NEWLINE character
  2912.        is returned by getlin.  If the  file  contains  characters
  2913.        in  a  representation other than ascii, the characters are
  2914.        mapped   (via   inmap)   into   their    internal    ascii
  2915.        representation.
  2916.  
  2917.        Getlin  generally assumes a maximum size of the array line
  2918.        passed to it (MAXLINE).  If the  input  line  exceeds  the
  2919.        limit,  either  truncate the line or return the rest of it
  2920.        in subsequent calls to getlin.
  2921.  
  2922.        Getlin and getch are  compatible;  that  is,  interspersed
  2923.        calls  to  getlin and getch are allowed and work properly.
  2924.        A common implementation  is  to  have  getlin  call  getch
  2925.        until   a  NEWLINE  character  is  found  (or  MAXLINE  is
  2926.        reached).
  2927.  
  2928.  
  2929.  
  2930.                                -1-
  2931.  
  2932.  
  2933.  
  2934.  
  2935. GETLIN (2)                  11/10/78                   GETLIN (2)
  2936.  
  2937.  
  2938.        Getlin is able to recognize end-of-file  marks  from  both
  2939.        terminals and files.
  2940.  
  2941. SEE ALSO
  2942.        getch, putch, putlin
  2943.  
  2944. DIAGNOSTICS
  2945.        None    #-t-    getlin                       2028    local
  2946.        01/07/81  22:51:05 #-h-   gettyp                      1604
  2947.        local   01/07/81  22:51:06
  2948.  
  2949.  
  2950.  
  2951.  
  2952.  
  2953.  
  2954.  
  2955.  
  2956.  
  2957.  
  2958.  
  2959.  
  2960.  
  2961.  
  2962.  
  2963.  
  2964.  
  2965.  
  2966.  
  2967.  
  2968.  
  2969.  
  2970.  
  2971.  
  2972.  
  2973.  
  2974.  
  2975.  
  2976.  
  2977.  
  2978.  
  2979.  
  2980.  
  2981.  
  2982.  
  2983.  
  2984.  
  2985.  
  2986.  
  2987.  
  2988.  
  2989.  
  2990.  
  2991.                                -2-
  2992.  
  2993.  
  2994.  
  2995.  
  2996. GETTYP (2)                   01/7/81                   GETTYP (2)
  2997.  
  2998.  
  2999. NAME
  3000.        gettyp - get type of file (character or binary)
  3001.  
  3002. SYNOPSIS
  3003.        type = gettyp (name)
  3004.  
  3005.        character name(FILENAMESIZE)
  3006.        integer type returned as ASCII, LOCAL, BINARY
  3007.  
  3008. DESCRIPTION
  3009.        'Gettyp'  determines  whether the file specified by 'name'
  3010.        is ascii characters, local characters (if  different  from
  3011.        ascii),  or binary.  The type is returned as ASCII, LOCAL,
  3012.        or BINARY in the functional call.
  3013.  
  3014.  
  3015. IMPLEMENTATION
  3016.        A  file's  type  may  be  determined  by  locating  system
  3017.        information  about  the  file,  or  'gettyp' might have to
  3018.        actually open the file and  read  part  of  it,  making  a
  3019.        reasonable 'guess' as to its flavor.
  3020.  
  3021.        The  shell  uses  'gettyp'  to determine whether a command
  3022.        verb given by the user represents  a  script  file  or  an
  3023.        executable  tool.  If the file turns out to be a character
  3024.        (i.e. script) file, the shell then spawns itself with  the
  3025.        file  as  input.   Thus, if 'gettyp' could not be reliably
  3026.        implemented on a particular system, the  user  would  have
  3027.        to specifically execute her script files by:
  3028.                             % sh script ...
  3029.  
  3030.        'Gettyp'  may  also  be  called by the archiver to store a
  3031.        file's type  in  the  archive  header  (for  informational
  3032.        purposes only).
  3033.  
  3034.        This  primitive is not considered finalized.  Most likely,
  3035.        another primitive will be specified which is used to  pick
  3036.        up  an  assortment  of information about a file.  'Gettyp'
  3037.        is being used  temporarily  until  the  final  version  is
  3038.        specified.
  3039.  
  3040. SEE ALSO
  3041.  
  3042. DIAGNOSTICS
  3043.        ERR   is   returned  if  the  file  does  not  exist  #-t-
  3044.        gettyp                        1604     local      01/07/81
  3045.        22:51:06   #-h-   initst                      1818   local
  3046.        01/07/81  22:53:20
  3047.  
  3048.  
  3049.  
  3050.  
  3051.  
  3052.                                -1-
  3053. ì
  3054.  
  3055.  
  3056.  
  3057. INITST (2)                  11/10/78                   INITST (2)
  3058.  
  3059.  
  3060. NAME
  3061.        initst  -  initialize  all  standard  files   and   common
  3062.        variables needed for the software tools primitives
  3063.  
  3064. SYNOPSIS
  3065.        call initst
  3066.  
  3067. DESCRIPTION
  3068.        This  routine is generally the first routine called by any
  3069.        program desiring to use  the  software  tools  primitives.
  3070.        It  opens  STDIN, STDOUT, and ERROUT files, performing any
  3071.        file substitutions indicated  on  the  command  line.   It
  3072.        also  prepares  the list of arguments needed by getarg and
  3073.        sets  up  any  buffers,  variables,  etc.  needed  by  the
  3074.        software tools primitives.
  3075.  
  3076.        On  many  systems,  the  calls to 'initst' and 'endst' are
  3077.        done   automatically   either   by   having   the   ratfor
  3078.        preprocessor  insert  them into the code, or by having the
  3079.        system  itself  call  them  before  executing  the  user's
  3080.        program.
  3081.  
  3082. IMPLEMENTATION
  3083.        'Initst'   initializes   any   common  blocks,  variables,
  3084.        buffers, arrays, or whatever is  necessary  to  allow  the
  3085.        other  software  tools primitives to operate.  It may also
  3086.        have to  retrieve  (via  'makarg')  the  list  of  command
  3087.        arguments   passed   to   the  program,  if  this  is  not
  3088.        automatically available from the operating system.
  3089.  
  3090.        'Initst' is also responsible for parsing the command  line
  3091.        to  determine  if  there  have been any file substitutions
  3092.        for STDIN,  STDOUT,  or  ERROUT.   The  appropriate  files
  3093.        (either  the  user's  terminal  or  the substitutions) are
  3094.        then opened and  properly  positioned.   Arrangements  are
  3095.        made   so  that  'getarg'  won't  pick  up  standard  file
  3096.        substitution flags on  subsequent  calls  (probably  by  a
  3097.        call to 'delarg').
  3098.  
  3099. SEE ALSO
  3100.        endst, getarg, delarg
  3101.  
  3102.  
  3103. DIAGNOSTICS
  3104.        If  initst  cannot  function  for some reason, the program
  3105.        generally aborts (possibly without an error message  since
  3106.        the  standard  error file may not have been opened).  #-t-
  3107.        initst                        1818     local      01/07/81
  3108.        22:53:20   #-h-   isatty                       893   local
  3109.        01/07/81  22:51:07
  3110.  
  3111.  
  3112.  
  3113.                                -1-
  3114.  
  3115.  
  3116.  
  3117.  
  3118. ISATTY (2)                  11/13/78                   ISATTY (2)
  3119.  
  3120.  
  3121. NAME
  3122.        isatty - determine if file is a teletype/CRT device
  3123.  
  3124. SYNOPSIS
  3125.        stat = isatty (fd)
  3126.  
  3127.        filedes fd
  3128.        integer stat returned as YES/NO
  3129.  
  3130. DESCRIPTION
  3131.        This function returns YES if the file  specified  by  'fd'
  3132.        is  a teletype-like device, otherwise it returns NO.  'Fd'
  3133.        is a file  descriptor  returned  by  a  call  to  open  or
  3134.        create.
  3135.  
  3136. IMPLEMENTATION
  3137.        When  a  file  is opened, a flag is usually set indicating
  3138.        what device the file is associated  with.   This  function
  3139.        generally  reads  that  flag.   Other  implementations are
  3140.        possible, depending upon the operating system involved.
  3141.  
  3142.        'Isatty' is generally  used  by  the  tools  to  determine
  3143.        whether they should issue prompts or not.
  3144.  
  3145. SEE ALSO
  3146.        open, create
  3147.  
  3148. DIAGNOSTICS
  3149.        NO    is   returned   if   'fd'   is   in   error.    #-t-
  3150.        isatty                         893     local      01/07/81
  3151.        22:51:07   #-h-   mkuniq                      1912   local
  3152.        01/07/81  22:53:21
  3153.  
  3154.  
  3155.  
  3156.  
  3157.  
  3158.  
  3159.  
  3160.  
  3161.  
  3162.  
  3163.  
  3164.  
  3165.  
  3166.  
  3167.  
  3168.  
  3169.  
  3170.  
  3171.  
  3172.  
  3173.  
  3174.                                -1-
  3175.  
  3176.  
  3177.  
  3178.  
  3179. MKUNIQ (2)                   6/5/79                    MKUNIQ (2)
  3180.  
  3181.  
  3182. NAME
  3183.        mkuniq - generate unique file name
  3184.  
  3185. SYNOPSIS
  3186.        len = mkuniq (seed, name)
  3187.  
  3188.        character seed(ARB), name(FILENAMESIZE)
  3189.        integer len returned as length/ERR
  3190.  
  3191. DESCRIPTION
  3192.        Mkuniq generates a "unique" file name from  a  given  seed
  3193.        string.   This  name  is  intended  for  use in subsequent
  3194.        calls to create  and  open.   "Len"  is  returned  as  the
  3195.        number  of  characters  in  "name",  not including the EOS
  3196.        marker.  If there was some problem in creating  the  name,
  3197.        ERR is returned.
  3198.  
  3199.        Mkuniq  is  generally  used  for  generating  scratch file
  3200.        names, such as those needed by the editor and archiver.
  3201.  
  3202.        On single-user systems or others where the  unique  naming
  3203.        of  scratch  files is not important, mkuniq simply returns
  3204.        "seed".  More sophisticated versions may construct a  file
  3205.        name   in   a   special  directory,  use  process  ids  or
  3206.        time-and-date to insure uniqueness.
  3207.  
  3208. IMPLEMENTATION
  3209.        'Mkuniq' is used to avoid conflicts which occur when  more
  3210.        than  one  user  is  logged  in  under  a  single  user or
  3211.        directory name.  The optimum implementation  would  be  to
  3212.        return  an  absolutely  unique  file name based on 'seed'.
  3213.        However, on most  systems  this  is  impossible.   Another
  3214.        solution  would  be  to  append  (or prepend) some sort of
  3215.        process identifier to 'seed', thus making  the  file  name
  3216.        at   least  unique  to  the  calling  process.   To  avoid
  3217.        privilege violations it might also be necessary to  choose
  3218.        a   specific   directory   for  all  scratch  files,  with
  3219.        appropriate privileges being assigned to it.
  3220.  
  3221.        On some systems, 'seed' is limited to a certain number  of
  3222.        characters.
  3223.  
  3224.        On  single-user  systems,  systems  with  local  files, or
  3225.        other circumstances where unique  file  names  are  not  a
  3226.        problem,   'mkuniq'   can  simply  return  the  'seed'  as
  3227.        'name'.
  3228.  
  3229. SEE ALSO
  3230.  
  3231.  
  3232. DIAGNOSTICS
  3233.  
  3234.  
  3235.                                -1-
  3236.  
  3237.  
  3238.  
  3239.  
  3240. MKUNIQ (2)                   6/5/79                    MKUNIQ (2)
  3241.  
  3242.  
  3243.        If a file name could not be generated,  ERR  is  returned.
  3244.        #-t-   mkuniq                      1912   local   01/07/81
  3245.        22:53:21  #-h-   note                        1444    local
  3246.        01/07/81  22:52:29
  3247.  
  3248.  
  3249.  
  3250.  
  3251.  
  3252.  
  3253.  
  3254.  
  3255.  
  3256.  
  3257.  
  3258.  
  3259.  
  3260.  
  3261.  
  3262.  
  3263.  
  3264.  
  3265.  
  3266.  
  3267.  
  3268.  
  3269.  
  3270.  
  3271.  
  3272.  
  3273.  
  3274.  
  3275.  
  3276.  
  3277.  
  3278.  
  3279.  
  3280.  
  3281.  
  3282.  
  3283.  
  3284.  
  3285.  
  3286.  
  3287.  
  3288.  
  3289.  
  3290.  
  3291.  
  3292.  
  3293.  
  3294.  
  3295.  
  3296.                                -2-
  3297.  
  3298.  
  3299.  
  3300.  
  3301. NOTE (2)                    11/13/78                     NOTE (2)
  3302.  
  3303.  
  3304. NAME
  3305.        note - determine current file position
  3306.  
  3307. SYNOPSIS
  3308.        stat = note (offset, fd)
  3309.  
  3310.        integer offset(2)
  3311.        filedes fd
  3312.        integer stat returned as OK/ERR
  3313.  
  3314. DESCRIPTION
  3315.        Note  determines  the current value of a file's read/write
  3316.        pointer.  The argument "offset" is a 2-word integer  array
  3317.        that  will  receive the information.  Offset is maintained
  3318.        untouched by the user and passed to "seek"  when  desiring
  3319.        to return to that particular location in the file.
  3320.  
  3321.        Note  is  usually  used  as  the  file  is  being written,
  3322.        picking up the pointer to the end of the file before  each
  3323.        record is inserted there.
  3324.  
  3325.        On  text  files  (e.g.  those  created  by calls to putch,
  3326.        putlin), note is guaranteed to  work  at  line  boundaries
  3327.        only.   However, it should work anywhere on a file created
  3328.        by calls to writef.
  3329.  
  3330. IMPLEMENTATION
  3331.        Note is compatible with whatever implementation is  chosen
  3332.        for seek and the opening of files at READWRITE access.
  3333.  
  3334.        Offset  is  a  two-word  integer  in  which  is  stored  a
  3335.        character count, word address, block and  record  address,
  3336.        or   whatever  is  appropriate  for  the  local  operating
  3337.        system.     Note    should    be    taught    to    return
  3338.        BEGINNING_OF_FILE and END_OF_FILE where appropriate.
  3339.  
  3340.        In  the  editor,  note is called to locate the end of file
  3341.        for subsequent writes.
  3342.  
  3343. SEE ALSO
  3344.        seek, readf, writef
  3345.  
  3346. DIAGNOSTICS
  3347.        None   #-t-    note                         1444     local
  3348.        01/07/81   22:52:29  #-h-  open                       3472
  3349.        local   01/07/81  22:51:08
  3350.  
  3351.  
  3352.  
  3353.  
  3354.  
  3355.  
  3356.  
  3357.                                -1-
  3358.  
  3359.  
  3360.  
  3361.  
  3362. OPEN (2)                    11/10/78                     OPEN (2)
  3363.  
  3364.  
  3365. NAME
  3366.        open - open an existing  file  for  reading,  writing,  or
  3367.        both
  3368.  
  3369. SYNOPSIS
  3370.        fd = open (name, access)
  3371.  
  3372.        character name(FILENAMESIZE)
  3373.        integer access
  3374.        filedes fd - returned as file descriptor/ERR
  3375.  
  3376. DESCRIPTION
  3377.        Open  opens the file whose name is contained in "name" for
  3378.        I/O according to the value of "mode", which may  be  READ,
  3379.        WRITE,  READWRITE,  or APPEND.  If the file exists and can
  3380.        be  opened  according  to  "mode",  open  returns  a  file
  3381.        descriptor.    If  the  file  cannot  be  opened,  ERR  is
  3382.        returned.
  3383.  
  3384.        After  a  file  is  opened,  it  is  positioned   at   the
  3385.        beginning,  unless  APPEND  access  is requested, in which
  3386.        case the file is prepared for extension.
  3387.  
  3388.        Opening the same  file  for  reading  more  than  once  is
  3389.        permissible   and   works  correctly.   However,  on  many
  3390.        systems a file may be opened only once in  WRITE,  APPEND,
  3391.        or READWRITE mode.
  3392.  
  3393.        There  is  generally  a  limit to the number of files that
  3394.        can be opened simultaneously.  This  number  is  specified
  3395.        by   the   definition  MAXOFILES  in  the  general  symbol
  3396.        definition file.
  3397.  
  3398. IMPLEMENTATION
  3399.        Open attaches an existing file to a  running  program  and
  3400.        associates   the  external  file  name  with  an  internal
  3401.        identifier which is then usable by the program.  The  file
  3402.        is  opened for I/O according to the value of "mode", where
  3403.        mode may be READ, WRITE, READWRITE, or APPEND.  "Name"  is
  3404.        passed  as  an ascii character array, stored one character
  3405.        per  array  element.   The  access  modes   READ,   WRITE,
  3406.        READWRITE,  and  APPEND  are global symbols defined in the
  3407.        standard definitions file.
  3408.  
  3409.        Open does whatever manipulations are  necessary  to  allow
  3410.        reading   and/or   writing   to  the  file.   An  internal
  3411.        descriptor (usually an integer) is assigned  to  the  file
  3412.        and  subsequently  used when calling other primitives such
  3413.        as close, getch, putch, getlin, and putlin.
  3414.  
  3415.        'Open' should be able to open a channel  to  the  teletype
  3416.  
  3417.  
  3418.                                -1-
  3419.  
  3420.  
  3421.  
  3422.  
  3423. OPEN (2)                    11/10/78                     OPEN (2)
  3424.  
  3425.  
  3426.        in  responce  to  the filenames defined by TERMINAL_IN and
  3427.        TERMINAL_OUT.  It also  might  be  taught  to  respond  to
  3428.        other device names where appropriate.
  3429.  
  3430.        Open  may  have  to  set up an internal I/O buffer for the
  3431.        file.  It may also  have  to  determine  the  file's  type
  3432.        (teletype,  character  file,  binary  file).   Information
  3433.        about the file's type and  teletype  characteristics  (yes
  3434.        or  no)  is generally maintained and made available to the
  3435.        user via "isatty" and possibly other file  characteristics
  3436.        primitives.
  3437.  
  3438.        Open  is sometimes taught to read characters of ascii type
  3439.        as  well  as  local  character  type   (if   not   ascii).
  3440.        Translation  of  characters  from  local  to ascii is done
  3441.        when the characters are passed to getch and getlin.
  3442.  
  3443.        Opening a fresh instance of  an  already  opened  file  is
  3444.        permissible  and  does not affect the position of the file
  3445.        as accessed by subsequent or previous calls.
  3446.  
  3447.        There is generally a limit to the maximum number of  files
  3448.        open at any one time.  10-15 is a common range.
  3449.  
  3450.        READWRITE   access   may   cause   problems,  or  even  be
  3451.        impossible on many systems.  The  only  tool  which  needs
  3452.        this  access  is  the  editor.   If  necessary,  READWRITE
  3453.        access may be implemented by opening the file  twice--once
  3454.        at READ and once at WRITE access.
  3455.  
  3456. SEE ALSO
  3457.        create,  close, remove, getch, putch, readf, writef, seek,
  3458.        note, isatty
  3459.  
  3460. DIAGNOSTICS
  3461.        Open returns ERR if the file does not  exist,  if  one  of
  3462.        the  necessary  directories  (if any) does not exist or is
  3463.        unreadable, if the file is not readable/writeable,  or  if
  3464.        too       many       files       are      open.       #-t-
  3465.        open                          3472     local      01/07/81
  3466.        22:51:08   #-h-   prompt                      1058   local
  3467.        01/07/81  22:52:30
  3468.  
  3469.  
  3470.  
  3471.  
  3472.  
  3473.  
  3474.  
  3475.  
  3476.  
  3477.  
  3478.  
  3479.                                -2-
  3480.  
  3481.  
  3482.  
  3483.  
  3484. PROMPT (2)                   6/5/79                    PROMPT (2)
  3485.  
  3486.  
  3487. NAME
  3488.        prompt - prompt user for input
  3489.  
  3490. SYNOPSIS
  3491.        call prompt (str, buf, fd)
  3492.  
  3493.        character str(ARB), buf(MAXLINE)
  3494.        filedes fd
  3495.  
  3496. DESCRIPTION
  3497.        Prompt  determines  if  "fd"  refers  to  a  teletype-like
  3498.        device  and,  if so, writes the prompt string "str" to the
  3499.        TTY, and flushes its output buffer to  insure  the  prompt
  3500.        is  printed.   A  line  of  input  is then read from fd by
  3501.        "getlin".
  3502.  
  3503.        No carriage  return/line  feed  sequence  is  done  unless
  3504.        specified by a NEWLINE in the prompt string.
  3505.  
  3506. IMPLEMENTATION
  3507.        The version of 'prompt' on the tape is essentially:
  3508.  
  3509.                  if (isatty(fd) == YES)
  3510.                       {
  3511.                       call putlin(str, fd)
  3512.                       call flush (fd)
  3513.                       stat = getlin (buf, fd)
  3514.                       }
  3515.        Note  that  prompt  expects  to  be  able to read from and
  3516.        write to 'fd'.  If this is not possible  on  your  system,
  3517.        modify  prompt  to open a separate channel to the teletype
  3518.        for the write.
  3519.  
  3520. SEE ALSO
  3521.        putlin, remark, flush, isatty
  3522.  
  3523. DIAGNOSTICS
  3524.        None   #-t-    prompt                       1058     local
  3525.        01/07/81   22:52:30  #-h-  putch                       921
  3526.        local   01/07/81  22:52:31
  3527.  
  3528.  
  3529.  
  3530.  
  3531.  
  3532.  
  3533.  
  3534.  
  3535.  
  3536.  
  3537.  
  3538.  
  3539.  
  3540.                                -1-
  3541.  
  3542.  
  3543.  
  3544.  
  3545. PUTCH (2)                   11/10/78                    PUTCH (2)
  3546.  
  3547.  
  3548. NAME
  3549.        putch - write character to file
  3550.  
  3551. SYNOPSIS
  3552.        call putch (c, fd)
  3553.  
  3554.        character c
  3555.        filedes fd
  3556.  
  3557. DESCRIPTION
  3558.        Putch writes the character c onto the  file  specified  by
  3559.        file  descriptor "fd".  If c is the NEWLINE character, the
  3560.        appropriate action is taken to indicate  the  end  of  the
  3561.        record  on  the  file.   The character is assumed to be in
  3562.        ascii format; however, if the output file is not of  ascii
  3563.        type, the necessary conversion is done.
  3564.  
  3565. IMPLEMENTATION
  3566.        Interspersed  calls  to  putch  and  putlin work properly.
  3567.        One implementation is  to  have  putlin  perform  repeated
  3568.        calls to putch.
  3569.  
  3570.        If  the  output  file  is not ascii, characters are mapped
  3571.        into their corresponding format via the routine outmap.
  3572.  
  3573. SEE ALSO
  3574.        putc, putlin, getch, getlin, readf, writef
  3575.  
  3576. DIAGNOSTICS
  3577.        None   #-t-    putch                         921     local
  3578.        01/07/81   22:52:31  #-h-  putlin                     1385
  3579.        local   01/07/81  22:52:32
  3580.  
  3581.  
  3582.  
  3583.  
  3584.  
  3585.  
  3586.  
  3587.  
  3588.  
  3589.  
  3590.  
  3591.  
  3592.  
  3593.  
  3594.  
  3595.  
  3596.  
  3597.  
  3598.  
  3599.  
  3600.  
  3601.                                -1-
  3602.  
  3603.  
  3604.  
  3605.  
  3606. PUTLIN (2)                  11/10/78                   PUTLIN (2)
  3607.  
  3608.  
  3609. NAME
  3610.        putlin - output a line onto a given file
  3611.  
  3612. SYNOPSIS
  3613.        call putlin (line, fd)
  3614.  
  3615.        character line(ARB)
  3616.        filedes fd
  3617.  
  3618. DESCRIPTION
  3619.        Putlin writes the characters in "line" to the file  opened
  3620.        on  file  descriptor  "fd".   If  a  NEWLINE  character is
  3621.        located, appropriate  action  is  taken  to  indicate  the
  3622.        end-of-record  in  whatever  format  is  necessary for the
  3623.        local  operating  system.   If  no  NEWLINE  character  is
  3624.        specified,   no  carriage  return  (or  end-of-record)  is
  3625.        assumed.  This probably means that the output buffer  will
  3626.        not be flushed.
  3627.  
  3628.        Any  necessary character translation is done if the output
  3629.        file is not of ascii type.
  3630.  
  3631. IMPLEMENTATION
  3632.        Putlin should write the line  onto  the  file  and,  if  a
  3633.        NEWLINE  is  encountered,  do  whatever  is  necessary  to
  3634.        indicate to the local operating system that a  record  has
  3635.        been   generated.   If  the  output  file  is  to  contain
  3636.        characters in  a  representation  other  than  ascii,  the
  3637.        characters  are  mapped  (via  outmap)  into  their proper
  3638.        representation.
  3639.  
  3640.        Putlin and putch are  compatible;  that  is,  interspersed
  3641.        calls  to  putlin and putch are allowed and work properly.
  3642.        A common implementation  is  to  have  putlin  call  putch
  3643.        until an EOS marker is found.
  3644.  
  3645. SEE ALSO
  3646.        putch, prompt, remark, getch, getlin
  3647.  
  3648. DIAGNOSTICS
  3649.        None    #-t-    putlin                       1385    local
  3650.        01/07/81  22:52:32 #-h-   readf                       1244
  3651.        local   01/07/81  22:52:33
  3652.  
  3653.  
  3654.  
  3655.  
  3656.  
  3657.  
  3658.  
  3659.  
  3660.  
  3661.  
  3662.                                -1-
  3663.  
  3664.  
  3665.  
  3666.  
  3667. READF (2)                    6/30/78                    READF (2)
  3668.  
  3669.  
  3670. NAME
  3671.        readf - read from an opened file
  3672.  
  3673. SYNOPSIS
  3674.        count = readf (buf, n, fd)
  3675.  
  3676.        character buf(ARB)   or   integer buf(ARB)
  3677.        integer n
  3678.        filedes fd
  3679.        integer count returned as count/EOF
  3680.  
  3681. DESCRIPTION
  3682.        Readf  reads  "n" bytes (or words) from the file opened on
  3683.        file descriptor "fd" into the array "buf".  The bytes  (or
  3684.        words)  are  placed in "buf" one per array element.  Readf
  3685.        is the  typical  way  of  doing  binary  reads  on  files.
  3686.        Whether  buf  is  declared an integer or a character array
  3687.        is dependent upon which is most appropriate for  the  Φost
  3688.        operating system.
  3689.  
  3690.        Readf  returns  the  number  of bytes/words actually read.
  3691.        In most cases, this is equal to "n".  However, it  may  be
  3692.        less  if  an EOF has been encountered or if "fd" specified
  3693.        a device such as a terminal  where  less  than  "n"  bytes
  3694.        were input.
  3695.  
  3696. IMPLEMENTATION
  3697.        Readf  is  the typical way of implementing binary I/O.  Do
  3698.        whatever is necessary on your system  to  allow  users  to
  3699.        get at the file directly.
  3700.  
  3701.        If   reasonable,   design   readf   to  work  properly  in
  3702.        conjunction with getch and getlin.
  3703.  
  3704. SEE ALSO
  3705.        writef, getch, putch
  3706.  
  3707. DIAGNOSTICS
  3708.        None   #-t-    readf                        1244     local
  3709.        01/07/81   22:52:33  #-h-  remark                     1600
  3710.        local   01/07/81  22:52:34
  3711.  
  3712.  
  3713.  
  3714.  
  3715.  
  3716.  
  3717.  
  3718.  
  3719.  
  3720.  
  3721.  
  3722.  
  3723.                                -1-
  3724.  
  3725.  
  3726.  
  3727.  
  3728. REMARK (2)                  11/13/78                   REMARK (2)
  3729.  
  3730.  
  3731. NAME
  3732.        remark - print single-line message
  3733.  
  3734. SYNOPSIS
  3735.        call remark (message)
  3736.  
  3737.        integer message - message is a hollerith array
  3738.  
  3739. DESCRIPTION
  3740.        Remark writes the message onto  the  standard  error  file
  3741.        ERROUT.   A  NEWLINE  is always generated, even though one
  3742.        may not appear in  the  message.   The  message  array  is
  3743.        generally   a  Fortran  hollerith  string  in  the  format
  3744.        generated by the  Ratfor  quoted  string  capability.   On
  3745.        some  systems  it  may be necessary to indicate the end of
  3746.        the message with a period ".".  For example,
  3747.  
  3748.                call remark ("this is a warning message.")
  3749.  
  3750.        The escape character "@" may be used to  output  a  period
  3751.        (e.g.  @.)  and on some systems, the escape sequences "@t"
  3752.        and "@n" and "@b" may be used to output  a  TAB,  NEWLINE,
  3753.        and BACKSPACE respectively.
  3754.  
  3755. IMPLEMENTATION
  3756.        Remark  is  very  similar to error except it returns after
  3757.        printing, instead of stopping.  It  expects  its  argument
  3758.        to  be  a hollerith string which is produced by the ratfor
  3759.        quoted string capability.  If your system has  no  way  of
  3760.        determining  the  end of hollerith strings, you might have
  3761.        to require users to include a termination  character  such
  3762.        as  a  ".".  (All the quoted strings in the software tools
  3763.        source code do terminate with a dot.)
  3764.  
  3765.        Remark is similar to the  following,  except  the  message
  3766.        string is hollerith rather than character:
  3767.             call putlin (message, ERROUT)
  3768.             call putch  (NEWLINE, ERROUT)
  3769.  
  3770.  
  3771.  
  3772. SEE ALSO
  3773.        error, putlin, putch, prompt
  3774.  
  3775. DIAGNOSTICS
  3776.        None    #-t-    remark                       1600    local
  3777.        01/07/81  22:52:34 #-h-   remove                       916
  3778.        local   01/07/81  22:51:10
  3779.  
  3780.  
  3781.  
  3782.  
  3783.  
  3784.                                -1-
  3785.  
  3786.  
  3787.  
  3788.  
  3789. REMOVE (2)                  11/10/78                   REMOVE (2)
  3790.  
  3791.  
  3792. NAME
  3793.        remove - remove a file from the file system
  3794.  
  3795. SYNOPSIS
  3796.        stat = remove (filename)
  3797.  
  3798.        character filename(FILENAMESIZE)
  3799.        integer stat returned as OK/ERR
  3800.  
  3801. DESCRIPTION
  3802.        From  within  a  running  program,  remove (or delete) the
  3803.        file specified by "name" from the file system.  "Name"  is
  3804.        an  ascii character array.  The file need not be opened to
  3805.        be removed.
  3806.  
  3807.        If the file exists and can be  removed,  OK  is  returned.
  3808.        If  the  file does not exist or cannot be removed for some
  3809.        other reason, the function returns ERR.
  3810.  
  3811. IMPLEMENTATION
  3812.        The file to be  removed  need  not  be  connected  to  the
  3813.        running  program.   However,  if  it is, remove closes the
  3814.        file before removing it.
  3815.  
  3816.  
  3817. SEE ALSO
  3818.        open, close, create
  3819.  
  3820. DIAGNOSTICS
  3821.        If the file  does  not  exist  the  routine  returns  ERR.
  3822.        #-t-   remove                       916   local   01/07/81
  3823.        22:51:10  #-h-   seek                        1551    local
  3824.        01/07/81  22:52:35
  3825.  
  3826.  
  3827.  
  3828.  
  3829.  
  3830.  
  3831.  
  3832.  
  3833.  
  3834.  
  3835.  
  3836.  
  3837.  
  3838.  
  3839.  
  3840.  
  3841.  
  3842.  
  3843.  
  3844.  
  3845.                                -1-
  3846.  
  3847.  
  3848.  
  3849.  
  3850. SEEK (2)                    11/13/78                     SEEK (2)
  3851.  
  3852.  
  3853. NAME
  3854.        seek - move read/write pointer
  3855.  
  3856. SYNOPSIS
  3857.        call seek (offset, fd)
  3858.  
  3859.        integer offset(2)
  3860.        filedes fd
  3861.        integer stat returned as OK/ERR
  3862.  
  3863. DESCRIPTION
  3864.        Seek  moves  the  read/write pointer of the file specified
  3865.        by "fd" to a (previously  identified)  spot  specified  by
  3866.        "offset".   "Offset"  must  have  been  set  by  a call to
  3867.        "note", or its first element must be set  to  one  of  the
  3868.        constants  END_OF_FILE  or  BEGINNING_OF_FILE (definitions
  3869.        available in the standard symbols file).
  3870.  
  3871.        Once the file is positioned by a  call  to  seek,  reading
  3872.        can  be  done using the standard I/O calls (getch, getlin,
  3873.        readf).
  3874.  
  3875.        Seek can also be used for seeking to the  end  of  a  file
  3876.      á and performing a write (thus extending the file).
  3877.  
  3878.        Rewriting in place may not be allowed on some systems.
  3879.  
  3880. IMPLEMENTATION
  3881.        Seek   depends  heavily  upon  the  peculiarities  of  the
  3882.        operating system.  It  can  generally  be  used  on  files
  3883.        opened at READWRITE access.
  3884.  
  3885.        The  offset  units  are  chosen  to  be  whatever  is most
  3886.        appropriate for the system  involved:  characters,  words,
  3887.        records,  block  numbers,  line  numbers,  etc.  Two words
  3888.        have been allotted for "offset" although some systems  may
  3889.        not need that much.
  3890.  
  3891.        On   some   systems   READWRITE  access  may  have  to  be
  3892.        implemented by opening the file twice, once  at  READ  and
  3893.        once at WRITE access.
  3894.  
  3895.        'Seek'   should  be  made  compatible  with  the  standard
  3896.        reading and writing routines.
  3897.  
  3898. SEE ALSO
  3899.        note
  3900.  
  3901. DIAGNOSTICS
  3902.        None   #-t-    seek                         1551     local
  3903.        01/07/81   22:52:35  #-h-  spawn                      3024
  3904.  
  3905.  
  3906.                                -1-
  3907.  
  3908.  
  3909.  
  3910.  
  3911. SEEK (2)                    11/13/78                     SEEK (2)
  3912.  
  3913.  
  3914.        local   01/07/81  22:53:24
  3915.  
  3916.  
  3917.  
  3918.  
  3919.  
  3920.  
  3921.  
  3922.  
  3923.  
  3924.  
  3925.  
  3926.  
  3927.  
  3928.  
  3929.  
  3930.  
  3931.  
  3932.  
  3933.  
  3934.  
  3935.  
  3936.  
  3937.  
  3938.  
  3939.  
  3940.  
  3941.  
  3942.  
  3943.  
  3944.  
  3945.  
  3946.  
  3947.  
  3948.  
  3949.  
  3950.  
  3951.  
  3952.  
  3953.  
  3954.  
  3955.  
  3956.  
  3957.  
  3958.  
  3959.  
  3960.  
  3961.  
  3962.  
  3963.  
  3964.  
  3965.  
  3966.  
  3967.                                -2-
  3968.  
  3969.  
  3970.  
  3971.  
  3972. SPAWN (2)                   11/13/78                    SPAWN (2)
  3973.  
  3974.  
  3975. NAME
  3976.        spawn - execute subtask
  3977.  
  3978. SYNOPSIS
  3979.        stat = spawn(command, args, desc, waitflg)
  3980.  
  3981.        character command(ARB), args(ARB), desc(ARB), waitflg
  3982.        integer stat returned as OK/ERR
  3983.  
  3984. DESCRIPTION
  3985.        Spawn  is  called  to  cause  execution  of   a   subtask.
  3986.        'Command'   is   an   ascii  character  array  giving  the
  3987.        (file)name of the task to be executed.
  3988.  
  3989.        'Args' is an ascii  character  array  giving  the  command
  3990.        line   arguments   to  be  passed  to  the  subtask.   The
  3991.        arguments are separated by blanks and  the  entire  string
  3992.        is terminated with an EOS marker.
  3993.  
  3994.        'Desc'  is  returned as a character array containing an ID
  3995.        for the spawned subtask.  This ID may  be  passed  to  the
  3996.        'pstat',  'suspnd',  'resume',  and 'kill' process control
  3997.        tools (if implemented).
  3998.  
  3999.        'Waitflg' is  a  flag  indicating  whether  or  not  spawn
  4000.        should  return  before execution of the task is completed.
  4001.        If WAIT is passed, spawn does not return  until  execution
  4002.        of  the  task  has  completed  (the  situation  for normal
  4003.        commands).  If NOWAIT is passed,  spawn  begins  execution
  4004.        of  the  task  and  immediately returns (for use with real
  4005.        pipes).  If BACKGROUND is passed, spawn executes the  task
  4006.        as a background process and immediately returns.
  4007.  
  4008.        If  the  task  cannot  be  executed,  spawn  returns  ERR;
  4009.        otherwise it returns OK.
  4010.  
  4011.        Spawned tasks  must  be  properly  taught  to  read  their
  4012.        command  line  arguments  in  whatever  manner spawn sends
  4013.        them.
  4014.  
  4015. IMPLEMENTATION
  4016.        Spawn  is,  by  far,  the  most  difficult  primitive   to
  4017.        implement.   A  few  of  the major obstacles which must be
  4018.        overcome are:
  4019.  
  4020.          1. Does the target operating  system  permit  a  running
  4021.             process  to  spawn  a  subprocess?   If it provides a
  4022.             multi-user,   interactive   environment,   it    most
  4023.             certainly  does,  but  it may not be common knowledge
  4024.             as to how to do it.  For example, the  following  DEC
  4025.             implementations have been done by the LBL group:
  4026.  
  4027.  
  4028.                                -1-
  4029.  
  4030.  
  4031.  
  4032.  
  4033. SPAWN (2)                   11/13/78                    SPAWN (2)
  4034.  
  4035.  
  4036.               a) RSX11M  -  a  loadable  pseudo-driver is used to
  4037.                  stuff MCR commands into  MCR's  queue,  via  qio
  4038.                  requests.
  4039.  
  4040.               b) IAS  -  the TCS macros provided by the operating
  4041.                  system for custom  CLI  construction  are  used.
  4042.                  The  only  interface  is from assembly language,
  4043.                  so that is the language used.
  4044.  
  4045.               c) VMS - the sys$creprc system  service,  which  is
  4046.                  callable  from  any supported language, is used.
  4047.                  In fact, the entire spawn primitive  is  written
  4048.                  in ratfor.
  4049.  
  4050.          2. Once  one has determined how to spawn the process, it
  4051.             is necessary to determine how to control it.  If  the
  4052.             operating     system    does    not    provide    any
  4053.             synchronization   methods,   then   they   must    be
  4054.             implemented.
  4055.  
  4056.          3. Finally,  one  must  determine how to communicate the
  4057.             arguments  and   environment   information   to   the
  4058.             subprocess.   This  generally  entails an exploration
  4059.             of  the  system  provided  interprocess-communication
  4060.             mechanisms,  and  often  requires  the  invention  of
  4061.             better ones.
  4062.  
  4063.  
  4064. SEE ALSO
  4065.  
  4066. DIAGNOSTICS
  4067.        A message  'Cannot  spawn  process'  is  printed  if  that
  4068.        situation  occurs.   #-t-  spawn                      3024
  4069.        local            01/07/81           22:53:24          #-h-
  4070.        writef                        1093     local      01/07/81
  4071.        22:52:36
  4072.  
  4073.  
  4074.  
  4075.  
  4076.  
  4077.  
  4078.  
  4079.  
  4080.  
  4081.  
  4082.  
  4083.  
  4084.  
  4085.  
  4086.  
  4087.  
  4088.  
  4089.                                -2-
  4090.  
  4091.  
  4092.  
  4093.  
  4094. WRITEF (2)                   6/30/78                   WRITEF (2)
  4095.  
  4096.  
  4097. NAME
  4098.        writef - write to an opened file
  4099.  
  4100. SYNOPSIS
  4101.        count = writef (buf, n, fd)
  4102.  
  4103.        character buf(ARB)   or   integer buf(ARB)
  4104.        integer n
  4105.        filedes fd
  4106.        integer count returned as count/ERR
  4107.  
  4108. DESCRIPTION
  4109.        Writef writes "n" bytes from the array "buf" to  the  file
  4110.        opened  on  file  descriptor  "fd".  Writef is the typical
  4111.        way of doing binary  writes  to  files.   Whether  buf  is
  4112.        declared  an  integer  or  a  character array is dependent
  4113.        upon which is most  appropriate  for  the  host  operating
  4114.        system.
  4115.  
  4116.        Writef   returns   the   number  of  bytes/words  actually
  4117.        written.  In most  cases,  this  is  equal  to  "n".   If,
  4118.        however, a write error occurs, writef returns ERR.
  4119.  
  4120. IMPLEMENTATION
  4121.        Writef  is the typical way of implementing binary I/O.  Do
  4122.        whatever is necessary on your system  to  allow  users  to
  4123.        get at the file directly.
  4124.  
  4125.        If   reasonable,   design   writef  to  work  properly  in
  4126.        conjunction with putch and putlin.
  4127.  
  4128. SEE ALSO
  4129.        readf, putch, putlin
  4130.  
  4131. DIAGNOSTICS
  4132.        None   #-t-    writef                       1093     local
  4133.        01/07/81  22:52:36
  4134.  
  4135.  
  4136.  
  4137.  
  4138.  
  4139.  
  4140.  
  4141.  
  4142.  
  4143.  
  4144.  
  4145.  
  4146.  
  4147.  
  4148.  
  4149.  
  4150.                                -1-
  4151.  
  4152.  
  4153.  
  4154.  
  4155.  
  4156.  
  4157.  
  4158.  
  4159.  
  4160.  
  4161.  
  4162.  
  4163.  
  4164.  
  4165.  
  4166.  
  4167.  
  4168.  
  4169.  
  4170.  
  4171.  
  4172.  
  4173.  
  4174.  
  4175.  
  4176.  
  4177.  
  4178.  
  4179.  
  4180.  
  4181.  
  4182.  
  4183.  
  4184.  
  4185.  
  4186.  
  4187.  
  4188.  
  4189.  
  4190.  
  4191.  
  4192.  
  4193.  
  4194.  
  4195.  
  4196.  
  4197.  
  4198.  
  4199.  
  4200.